![]() |
|
sfLanguageSwitchPlugin - 0.0.5Language switcher for symfony |
|
![]() |
25
users
Sign-in
to change your status |
This plugin gives you a component to include a simple language switcher. It holds the current URL and changes the sf_culture parameter. |
This plugin gives you a component to include a simple language switcher. It holds the current URL and changes the sf_culture parameter.
| Name | Status | |
|---|---|---|
|
|
lead | ten.zesom <<ta>> bt |
Copyright (c) 2008 Thomas Boerger
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| Version | License | API | Released |
|---|---|---|---|
| 0.0.5stable | MIT license | 0.0.5stable | 05/05/2009 |
| 0.0.3stable | MIT license | 0.0.3stable | 16/11/2008 |
| Version | License | API | Released |
|---|---|---|---|
| 0.0.5stable | MIT license | 0.0.5stable | 05/05/2009 |
| 0.0.3stable | MIT license | 0.0.3stable | 16/11/2008 |
| 0.0.2beta | MIT license | 0.0.2beta | 03/09/2008 |
| Version | License | API | Released |
|---|---|---|---|
| 0.0.5stable | MIT license | 0.0.5stable | 05/05/2009 |
| 0.0.3stable | MIT license | 0.0.3stable | 16/11/2008 |
| 0.0.2beta | MIT license | 0.0.2beta | 03/09/2008 |
| 0.0.1beta | MIT license | 0.0.1beta | 16/05/2008 |
The sfLanguageSwitchPlugin is a symfony plugin that provides a simple language switch generator. The available languages depends on the settings from app.yml. You have to call a simple component only and you will get a list of flags to switch the interface language.
Install the plugin
php symfony plugin-install http://plugins.symfony-project.com/sfLanguageSwitchPlugin
Enable the module in your settings.yml
all:
.settings:
enabled_modules: [sfLanguageSwitch]
Clear you cache
php symfony cc
Add the available languages and settings to app.yml
all:
sfLanguageSwitch:
flagPath: /sfLanguageSwitch/images/flag # optional if you wanna change the path
availableLanguages:
de:
title: Deutsch
en:
title: English
image: /sfLanguageSwitch/images/flag/us.png # optional if you wanna change the flag
Change your routing on routing.yml
homepage:
url: /
param: { sf_culture: de, module: home, action: index }
default_index:
url: /:sf_culture/:module
requirements: { sf_culture: (?:en|de) }
param: { action: index }
default:
url: /:sf_culture/:module/:action/*
requirements: { sf_culture: (?:en|de) }
Install the plugin
php symfony plugin:install sfLanguageSwitchPlugin
Enable the module in your settings.yml
all:
.settings:
enabled_modules: [sfLanguageSwitch]
Clear you cache
php symfony cc
Add the available languages and settings to app.yml
all:
sfLanguageSwitch:
flagPath: /sfLanguageSwitch/images/flag # optional if you wanna change the path
availableLanguages:
de:
title: Deutsch
en:
title: English
image: /sfLanguageSwitch/images/flag/us.png # optional if you wanna change the flag
Change your routing on routing.yml
homepage:
url: /
param: { sf_culture: de, module: home, action: index }
default_index:
url: /:sf_culture/:module
requirements: { sf_culture: (?:en|de) }
param: { action: index }
default:
url: /:sf_culture/:module/:action/*
requirements: { sf_culture: (?:en|de) }
If you have done the installation steps above you only got to call the component within you layout or module template like this:
<?php include_component('sfLanguageSwitch', 'get') ?>
By default, sfLanguageSwitch module comes with 1 very simple template:
If you want to customize this template:
Create a sfLanguageSwitch module in your application (don't use the init-module task, just create a sfLanguageSwitch directory)
Create a template with the name of the template you want to customize in the sfLanguageSwitch/templates directory
symfony now renders your template instead of the default one
