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
Comments
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.
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
You will have to get the title field of an image directly and pass that to this function.
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
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.
`
<?php if (isset($_GET['loc'])) {<br />
$locale = $_GET['loc'];
} else {
$locale = getOption('locale');
}
global $_zp_gallery;
?>
<?php echo '<?xml version="1.0"?>'; ?>
<?php echo $locale ?>
<![CDATA[<?php echo get_language_string(getOption('website_title'),$locale); ?>]]>
<![CDATA[<?php echo get_language_string(getOption('gallery_title'),$locale); ?>]]>
<![CDATA[<?php echo get_language_string(getOption('Gallery_description'),$locale); ?>]]>
<?php while (next_album()): ?>
<![CDATA[<?php echo get_language_string($_zp_current_album->get('title'),$locale); ?>]]>
<![CDATA[<?php echo get_language_string($_zp_current_album->get('desc'),$locale); ?>]]>
<![CDATA[<?php echo get_language_string($_zp_current_album->get('custom_data'),$locale); ?>]]>
<?php echo $_zp_current_album->get('id'); ?>
<?php $subalbums = $_zp_current_album->getSubalbums();
foreach ($subalbums as $subalbum) {
$album = new Album($_zp_gallery, $subalbum); ?>
<![CDATA[<?php echo get_language_string($album->get('title'),$locale); ?>]]>
<![CDATA[<?php echo get_language_string($album->get('desc'),$locale); ?>]]>
<![CDATA[<?php echo get_language_string($album->get('custom_data'),$locale); ?>]]>
<?php echo $album->get('id'); ?>
<?php $images = $album->getImages();
foreach ($images as $image) {
$imageobj = new _Image($album, $image); ?>
<![CDATA[<?php echo get_language_string($imageobj->get('title'),$locale); ?>]]>
<?php echo $imageobj->get('id'); ?>
<?php echo $album->get('id'); ?>
<![CDATA[<?php echo get_language_string($imageobj->get('desc'),$locale) ?>]]>
<![CDATA[<?php echo get_language_string($imageobj->get('custom_data'),$locale); ?>]]>
<?php } ?>
<?php } ?>
<?php $images = $_zp_current_album->getImages();
foreach ($images as $image) {
$imageobj = new _Image($_zp_current_album, $image); ?>
<![CDATA[<?php echo get_language_string($imageobj->get('title'),$locale); ?>]]>
<?php echo $imageobj->get('id'); ?>
<?php echo $_zp_current_album->get('id'); ?>
<![CDATA[<?php echo get_language_string($imageobj->get('desc'),$locale) ?>]]>
<![CDATA[<?php echo get_language_string($imageobj->get('custom_data'),$locale); ?>]]>
<?php } ?>
<?php endwhile; ?>
<?php $pages = getPages(true);<br />
foreach($pages as $page) {
$pageobj = new ZenpagePage($page['titlelink']);?>
getTitleLink();?>"><![CDATA[<?php echo get_language_string($pageobj->get("title"),$locale); ?>]]>
<?php } ?>
<?php if(function_exists("printAllNewsCategories")) { ?>
">
<?php } ?>
`