Member
Member
flu   27-08-2008, 19:28
#1

Hi,
I was wondering if it's possible to add directly in the php theme files some additionnal infos depending on the selected language. Let's get clearer, for example :
"freedom fries" but only if the english language is selected
"gut kartofel" for german language
"we don't call it "french fries" anymore, you bloody bastard" if the french language is selected
"learn english, you moron, anyway there's no potato in your damn insignificant country, I can't believe you can even use a computer" for any other language selected, etc.

1.Is this technically possible ? (no need to store these datas in the database, it would just be added directly in the index.php theme file)
2.If it's possible, what would be the regular expression to use it ?

Note : If you don't speak english, german or french, well, this is just an example, huhuhu ! Sorry.

Member
Member
sbillard   27-08-2008, 22:58
#2

You can certainly do that. There is an option--locale which tells you which language (actually locale) is selected. So you can just insert a switch statement into your theme:

switch (getOption('locale')) { default: case 'en_US': echo Me gusta las patatas fritas.'; break; case 'fr_FR': echo 'eh bien les pommes frits.'; break; case 'de_DE': echo 'Bratkartoffein sint fur den hunden.' }

Member
Member
flu   28-08-2008, 09:47
#3

Hi,
thank you, thank you, thank you Stephen, this is just wonderful !
I can't even remember how I published my pictures before I use ZP !
Woaw !

Member
Member
suxab   10-09-2008, 11:43
#4

Hi all,

I have problem with automatic language selection (HttpAcceptLanguage). I want to make an alias "hu" or "sk" for ISO standards (hu_HU, sk_SK) becouse not configured browsers of visitors returning just the brief code (hu, sk)
So, is it posibble to use this method for switching language of zenphoto by this way?

switch (getOption('locale')) { case 'hu': setlocale(LC_ALL, hu_HU); break; case 'sk': setlocale(LC_ALL, sk_SK); break;
thanks

Member
Member
sbillard   10-09-2008, 17:40
#5

Here is how I would do it:
function getUserLocale() { if (DEBUG_LOCALE) debugLogBackTrace("getUserLocale()"); $cookiepath = WEBPATH; if (WEBPATH == '') { $cookiepath = '/'; } if (isset($_POST['dynamic-locale'])) { $locale = sanitize($_POST['dynamic-locale'], 0); zp_setCookie('dynamic_locale', $locale, time()+5184000, $cookiepath); if (DEBUG_LOCALE) debugLog("dynamic_locale post: $locale"); } else { $localeOption = getOption('locale'); $locale = zp_getCookie('dynamic_locale'); if (DEBUG_LOCALE) debugLog("locale from option: ".$localeOption.'; dynamic locale='.$locale); if (empty($localeOption) && ($locale === false)) { // if one is not set, see if there is a match from 'HTTP_ACCEPT_LANGUAGE' $languageSupport = generateLanguageList(); $userLang = parseHttpAcceptLanguage(); foreach ($userLang as $lang) { $l = strtoupper($lang['fullcode']); foreach ($languageSupport as $key=>$value) { if (strtoupper($key) == $l) { // we got a match $locale = $key; if (DEBUG_LOCALE) debugLog("locale set from HTTP Accept Language: ".$locale); break; } } } if ($locale === false) { // try partal matches foreach ($userLang as $lang) { $l = strtoupper($lang['fullcode']); foreach ($languageSupport as $key=>$value) { if (preg_match('/^'.strtoupper($key).'/', $l)) { // we got a partial match $locale = $key; if (DEBUG_LOCALE) debugLog("locale set from HTTP Accept Language (partial match): ".$locale); break; } } } } } } if ($locale !== false) { setOption('locale', $locale, false); } return $locale; }
This is a more general solution which will match up a language based on a partial match of the perfered local to the list of locales.

I will add this to the nightly build. Let us know if it does the job.

Member
Member
suxab   10-09-2008, 19:22
#6

Hi sbillard!

No, it´s not working for me, my primary detected language is still english.
my site is: http://wallpaperstock.sk
My output from list_locales.php :

`
Http Accept Languages:
Key code coef morecode fullcode
1.0-hu hu 1.0 hu
0.5-sk sk 0.5 sk

Supported locales:
Warning: system() has been disabled for security reasons in /domains1/do909200/public/www_root/list_locales.php on line 4
`
many thanks

Member
Member
sbillard   10-09-2008, 19:52
#7

Does zenphoto give you any error messages?

Member
Member
suxab   10-09-2008, 19:59
#8

no, everything work perfectly, exept this feature. when I set language manually it´s working too

Member
Member
sbillard   10-09-2008, 21:07
#9

Ok, I have determined the problem. But the fix hits some more files than just functions-i18n. You can either download the complete SVN or wait for tonight's build. Again, let me know if it works for you.

Member
Member
suxab   11-09-2008, 06:49
#10

Bingo!

it´s work, many thanks!

Member
Member
code   11-09-2008, 06:54
#11

That is your site? What did you do make your own theme or just add zenphoto functions into your existing page? Its awesome!

Member
Member
suxab   11-09-2008, 10:40
#12

Yes, that is my site. It is a pure zenphoto. My theme is based on the default-theme (steril-light version)

Member
Member
sbillard   11-09-2008, 17:12
#13

Glad to know it works. This will be a good improvement to zenphoto. Thanks for letting us know.

Member
Member
alex_paris   06-10-2008, 11:07
#14

@flu : your example is an insult for all the french people that just said "no" to your illegal war. If you agree all the lies that your president used, and all the iraq people and young american dead for ... nothing (or petrol, choose your best answer), it's up to you.
End of the conversation

Administrator
Administrator
acrylian   06-10-2008, 11:22
#15

Even if the example may be a little awkward, I would not take that too serious... Additionally here is not the place for any political statements. (No, I am not American). Thanks.

Member
Member
flu   06-10-2008, 19:31
#16

@alex_paris
Hé mon gars, visiblement l'expression "second degré" t'échappe complètement.
Tu as un problème avec les patates ?
Il faut croire qu'on a pas le même humour et que tu as du temps à perdre. Tant mieux pour toi.
En tout cas j'espère que le code de sbillard t'a été utile.

(translation : Hey, Dude, obviously the word "humor" means nothing to you.
Do you feel uncomfortable with potatoes ?
Visibly we don't laugh about the same things and you seem to have time to waste. Good for you.
Anyway I hope that you found the code given by sbillard useful.)

Member
Member
alex_paris   07-10-2008, 00:38
#17

ok je m'incline, j'avais pas vraiment repéré le second degré, donc toutes mes excuses :(

PS : oui, le code m'a également aidé :p

Translate : sorry i didn't see the "humor", so i do apologize

PS : yep, the code really helped me, that's the great point of the story

Member
Member
flu   07-10-2008, 15:07
#18

;)

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.