Language switcher


i would like to have a language switcher.Is there a function that we can change the "locale" at the config file?
If not, does anyone have a suggestion how to create one?

Thank you for your time.

Zend Framework, which is included with Omeka, has code for writing INI files that you could use to modify the "locale" config entry and write it back to the INI file.

Of course, the config.ini file would have to be writable by your web server for that to work (this isn't the case in a normal Omeka installation, but you can change those permissions).

Thank you for your response.
I think this solution will work!

Siguiendo esta solución, la función funciona así:


function switcher_locale($locale) {

// Load all sections from an existing config file, while skipping the extends.
$config = new Zend_Config_Ini('application/config/config.ini',
array('skipExtends' => true,
'allowModifications' => true));

// Modify a value
$config->site->locale = $locale;

// Write the config file
$writer = new Zend_Config_Writer_Ini(array('config' => $config,
'filename' => 'application/config/config.ini'));


Sólo queda pasar el código de idioma por $_GET o $_POST.

$locale = $_GET['locale'];
if($locale) {

This code for writing the new locale to the config file is good, but I wouldn't recommend using the second part of the code, which works through a GET parameter.

That would allow any user to change the display language of the site and that change would apply for all later users who don't specifically try to set a locale themselves.

Instead, I think it'd be more reasonable to use the switcher code as part of a plugin that only admins of the site can access.

The translation system isn't currently set up for having the language change from request to request, but we'll think about things we can do to make that kind of functionality easier (and safer) in future Omeka versions.

Tienes razón, esta es una solución no funciona bien ya que implica una edición del config.ini que no es sólo para un usuario particular sino que opera de forma general en el sitio. Intentaré buscar una funcionalidad de "switch" diferente.
Gracias por el seguimiento.