ZenphotoCMS Forum
Switching languages/locales within a template - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: Translating (https://forum.zenphoto.org/forum-8.html)
+--- Thread: Switching languages/locales within a template (/thread-5205.html)



Switching languages/locales within a template - reef - 19-05-2009

Hi,

I'm currently working on a theme for a multi language site and I would like to show the content in more than 1 language on a page. This means getting the content (such as a gallery description) for a specific locale or switching the locale before retrieving content.

In the documentation I could not find how to do this within a template.

Is this possible? If so how?

thanks,

Bob




Switching languages/locales within a template - sbillard - 19-05-2009

In the admin options there are two settings for local language. The first, the language selector should be set to its default--HTTP select Language. The second--the Multi-lingual checkbox should be checked.

It might also be necessary, depending on your users' browsers, to use the dynamic_locale plugin. (This if their browser does not supply their prefered language.)

With Multi-lingual checked each field (description, etc.) will have a version for each possible language. Just put your translation is the appropriate language spot.




Switching languages/locales within a template - reef - 19-05-2009

Thanks for your reply.

However I'm afraid my question probably was not as clear as it should have been.

I want to show the content for two languages on the same page not have the user switch or switch it depending on browser settings. The html of the page would, for example, always contain the description of the gallery in both languages.

Why you ask? :-)

Well I'm making a flash front-end to zen photo and I want it to load a xml file that contains both languages. So far everything works fine but now I have to make it multi-lingual :-)

If it is not possible to switch the language within a template the other option to set the language when loading the xml. Then I would load it once for each language.

I checked the dynamic_locale plugin but it appears to rely on post data which I think would not be practical for this application.

So is this possible? If so how?

thanks,

Bob




Switching languages/locales within a template - acrylian - 19-05-2009

It is possible to get the languages directly with this function: http://www.zenphoto.org/documentation/core/_functions-i18n.php.html#functionget_language_string
You will have to get the title field of an image directly and pass that to this function.




Switching languages/locales within a template - sbillard - 19-05-2009

By getting the title field directly acrylian means use the $object->get('title'); method rather than the getTitle() function. getTitle() will resolve the field to the chosen lanugage. get('title') gets the raw Database information which then needs to be processed for a particular desired language.




Switching languages/locales within a template - reef - 20-05-2009

Thanks!

It took some figuring out but it works now. I'll post my code later so it might be of some help if somebody else is looking for something similar in the future.

Bob




Switching languages/locales within a template - reef - 27-05-2009

So what I did was create a specific locale_xml.php that contains all the localised string for a specific locale. For example mysite.com?type=loc&loc=en_US retreives the English content. (Other possible types are html & xml)

It was not that hard to figure out all the parts of the xml but it did take a while. So I'm posting it here, hoping it might be of some use to somebody else.

`

]]>

]]>

]]>

get('title'),$locale); ?>]]>

get('desc'),$locale); ?>]]>

get('custom_data'),$locale); ?>]]>

get('title'),$locale); ?>]]>

get('desc'),$locale); ?>]]>

get('custom_data'),$locale); ?>]]>

get('title'),$locale); ?>]]>

get('desc'),$locale) ?>]]>

get('custom_data'),$locale); ?>]]>

get('title'),$locale); ?>]]>

get('desc'),$locale) ?>]]>

get('custom_data'),$locale); ?>]]>