Active language code in template
stephenju
Joined: 2005-07-05
Posts: 172 |
Posted: Tue, 2006-02-28 23:18 |
Is there a way to get the current language code in a template? Like 'en_GB' or 'zh_TW'? - |
|
stephenju
Joined: 2005-07-05
Posts: 172 |
Posted: Tue, 2006-02-28 23:18 |
Is there a way to get the current language code in a template? Like 'en_GB' or 'zh_TW'? - |
|
Posts: 8601
You'd have to add that value into the $template in your theme.inc. It is not in the tpl data by default.
$gallery->getActiveLanguageCode();
Posts: 172
OK. That will do. Thanks.
-
東方之朱
Posts: 172
I am trying to add lang into <html> element so the browser will render it correctly. But to do that, I have to mock with each theme I use. And I might (OK, I will) forget to update the changed theme files after each upgrade.
Will it be possible to have 'Content-Language' in the HTML header? This way the browser will know which language it is and render the page corrently (if the browser does it right) without mocking with the templates.
-
東方之朱
Posts: 172
BTW. The language code used in HTML header is kind of different from G2 locale code. For example, HTML requires 'zh-TW' for Traditional Chinese while G2 is using 'zh_TW'. But a simple str_replace will do just fine.
-
東方之朱
Posts: 8
can anyone explain more how it's work as i am so stupid?
I means in the .inc
$gallery->getActiveLanguageCode();
and
in the .tpl
THANKS!
Posts: 172
Create a directory called 'local' in the same directory as theme.tpl file then copy the theme.tpl file into the new 'local' directory and edit that copy.
Now at the begining of theme.tpl add the following code:
right before:
-
東方之朱
Posts: 69
If you have a look at http://gallery.felixsalomon.net/mtbuffalo you can see the actual language highlighted in the upper menu. But as soon as you view a photo (eg http://gallery.felixsalomon.net/mtbuffalo/Buffalo_30a.jpg.html) the highlighting doesn't work anymore. Although I'm using the same php in theme.inc/theme.tpl both times.
Any suggestions why that happens?
Cheers
Posts: 32509
Nice UI!
i guess you only added the template variable to album but not to photo pages.
Posts: 69
Hi Valiant!
Thank you!
Actually it's all done in the theme.tpl... so it shouldn't really make a difference whether I'm viewing a photo or an album.
Uuups, I've just noticed that the important piece of code is the one in theme.inc - and there it is in fact only in the showAlbumPage section defined!
Now it works after I've copied the code to the showPhotoPage function.
Thanx