Author Topic: tpl localisation  (Read 8620 times)

0 Members and 1 Guest are viewing this topic.

Offline rejetto

  • Administrator
  • Insane programmer
  • *
  • Posts: 12832
  • Country: it
    • View Profile
tpl localisation
« on: December 08, 2007, 09:03:55 AM »
what if i create a macro {{£name}} that automatically expands to Frank having this section in the template

[special:strings]
hey=you
name=Frank
msg=do the right thing


i thought of £ because it's like the L of language.

then it may become more powerful by having the section [special:stringsIT] and HFS would load it if %lang% (or something else) is IT.

Offline maverick

  • Insane poster
  • *****
  • Posts: 1052
  • Computer Solutions
    • View Profile
Re: tpl localisation
« Reply #1 on: December 08, 2007, 09:12:10 AM »

i thought of £ because it's like the L of language.


What character is that?  Kind of looks like the british pound currency symbol.  Where do I find it on the keyboard?
maverick

Offline parade

  • Tireless poster
  • ****
  • Posts: 138
    • View Profile
Re: tpl localisation
« Reply #2 on: December 08, 2007, 09:24:48 AM »
Where do I find it on the keyboard?

ALT-156  ;)

Offline rejetto

  • Administrator
  • Insane programmer
  • *
  • Posts: 12832
  • Country: it
    • View Profile
Re: tpl localisation
« Reply #3 on: December 08, 2007, 09:37:03 AM »
ok, i guess we'll have to use a more international character, like # or ! ;)

Offline bacter

  • Operator
  • Insane poster
  • *****
  • Posts: 682
    • View Profile
Re: tpl localisation
« Reply #4 on: December 08, 2007, 10:29:10 AM »
caracter could be &, often used as literal.

Problem is the 'someting else', as %lang% is not very useful. So i think a way to to it would be go back to the overload ?lang= or better ?spec=stringit, ?spec=stringfr ..

but it could be nicer ?sp=it , then use the value of %sp%  [special:url%sp%.tpl}}] to load stringsit.tpl

... I want to think more about it, because there may be some problems:

[special:strings] may be part of the template, that could help make translations more easy.
but for external ?
[special:url{{string%sp%}}]

and i don't like that %lang% depends of the browsers language.
your computer has no brain - use your own !

Offline Mars

  • Operator
  • Insane poster
  • *****
  • Posts: 1788
  • Country: 00
    • View Profile
Re: tpl localisation
« Reply #5 on: December 08, 2007, 12:16:00 PM »
 
Quote
and i don't like that %lang% depends of the browsers language.
Others we can be need or envy to like its existence

?lang=  ?spec=stringfr
you can use {{urlvar|lang}} or {{urlvar|sp}} to return what you want
and use something like

Short version:
[special:string]
{{section|string{{urlvar|sp}}|url{{urlvar|sp}}.tpl}}

It is already possible to make what you wish with what we have under the hand

Longer version:
[special:string]
%sym-{{urlvar|sp}}%

[sym-IT]
hey=you
name=Frank
msg=do the right thing

[sym-FR]
hey=Vous
name=Marcel
msg=fait les choses correctement

[sym-XX]
{{section|externalXX|urlXX.tpl}}


missing just macro {{£name}}       {{£msg}} return the correct message according what you pass with ?sp=IT

%sp% with ?sp= will never exist, bacter,forget this possibility

(I believe that that there also I am going to put myself him in back, but it is him who in begun with left mid and right) ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D


%var% must be reserved for the internal informattions in hfs, for the parameters URL it exist a macro self-important for that (read the wiki)
http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros#Data_getting

(I believe that that there also I am going to put myself him in back, but it is him who in begun with left mid and right) ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D

Why not

{{filevar|name|file.tpl}}

by sample  {{filevar|last-external-address|/hfs.ini}} return your external IP

%lang% will just return language using by user's browser

Otherwise there is that for the inconsolable of any javascript
Code: [Select]
<script language="JavaScript">
/*
Browser Language Redirect script- By JavaScript Kit
For this and over 400+ free scripts, visit http://www.javascriptkit.com
This notice must stay intact
*/

//Enter ISO 639-2 letter Language codes to detect (see: http://www.w3.org/WAI/ER/IG/ert/iso639.htm):
var langcodes=new Array("en", "fr", "es", "ja", "zh", "default")

//Enter corresponding redirect URLs (last one is for default URL):
var langredirects=new Array("index.htm", "french.htm", "spanish.htm", "japan.htm", "chinese.htm", "index.htm")

var languageinfo=navigator.language? navigator.language : navigator.userLanguage
var gotodefault=1

function redirectpage(dest){
if (window.location.replace)
window.location.replace(dest)
else
window.location=dest
}

for (i=0;i<langcodes.length-1;i++){
if (languageinfo.substr(0,2)==langcodes[i]){
redirectpage(langredirects[i])
gotodefault=0
break
}
}

if (gotodefault)
redirectpage(langredirects[langcodes.length-1])
</script>
;D
« Last Edit: December 09, 2007, 07:28:00 AM by rejetto »
FRENCH MEMBER : Si vous comprenez la langue française,  n'hésitez pas à l'utiliser pour une meilleure aide de ma part

Offline Foggy

  • Insane poster
  • *****
  • Posts: 806
    • View Profile
Re: tpl localisation
« Reply #6 on: December 09, 2007, 03:15:24 AM »
what if i create a macro {{£name}} that automatically expands to Frank having this section in the template

[special:strings]
hey=you
name=Frank
msg=do the right thing


i thought of £ because it's like the L of language.

then it may become more powerful by having the section [special:stringsIT] and HFS would load it if %lang% (or something else) is IT.

That would be very useful but how much of a performance hit would it have?
For the character I would use either !,$or&

Offline rejetto

  • Administrator
  • Insane programmer
  • *
  • Posts: 12832
  • Country: it
    • View Profile
Re: tpl localisation
« Reply #7 on: December 09, 2007, 07:26:44 AM »
as %lang% is not very useful. So i think a way to to it would be go back to the overload ?lang= or better ?spec=stringit, ?spec=stringfr ..

the url parameter would disappear at next request.
we need cookies for such job.
i could make macros for cookies.
in the while, i guess you can already handle cookies with javascript.

Quote
[special:strings] may be part of the template, that could help make translations more easy.
but for external ?
[special:url{{string%sp%}}]

just {{load}}
and the [special] would be inside the file.
« Last Edit: December 09, 2007, 07:32:55 AM by rejetto »

Offline rejetto

  • Administrator
  • Insane programmer
  • *
  • Posts: 12832
  • Country: it
    • View Profile
Re: tpl localisation
« Reply #8 on: December 09, 2007, 07:34:12 AM »
That would be very useful but how much of a performance hit would it have?

no idea.
you can test yourself. (since next build)
make such a template, then see the CPU load with one and the other.

Offline SilentPliz

  • Operator
  • Insane poster
  • *****
  • Posts: 1181
  • ....... chut ! shh!
    • View Profile
Re: tpl localisation
« Reply #9 on: December 15, 2007, 08:41:56 PM »
Bonsoir,   
Good evening,

J'essai de faire un template bilingue, anglais-français avec les nouvelles macros; cela a l'air de marcher en faisant une entrée:

I am trying to make a template bilingual, English and French with new macros; it seems to OK, by creating an entry:


[special:strings]
Welcome=Bienvenue
Current path=Chemin courant
folder(s)=Répertoire(s)
etc... etc...

Mais je voudrais que la bonne langue s'affiche, selon la langue du navigateur. Et je n'ai pas bien compris les entrées que je dois créer.
Si quelqu'un peut m'aiguiller ce serait sympa.

But I would that the right language appears, according to the language of the browser. And I did not quite understand the entries that I have to create.
If someone can help me it would be nice.


Merci.
Thank you.

Olivier
« Last Edit: December 15, 2007, 10:11:04 PM by SilentPliz »

Offline Foggy

  • Insane poster
  • *****
  • Posts: 806
    • View Profile
Re: tpl localisation
« Reply #10 on: December 16, 2007, 01:35:54 AM »
You have to create a list with both the English text and the French text not how you have it now with the english text being the string id for the french text.
eg
[special:strings]
Welcome_en=Welcome
Welcome_fr=Bienvenue
Path_en=Current Path
Path_fr=Chemin courant
etc...

And to call them, simply use the string id with %lang% on the end.
eg.
{{!Welcome_%lang%}}
{{!Path_%lang%}}

A french language browser would then be returned
Bienvenue
Chemin courant

An english language browser would be returned
Welcome
Current path



One problem I just thought of is if someone that doesn't have English or French as the default language in their browser tries to view your server, they aren't going to be returned any text, so I think it would be easier to have the text for each language in their own separate text file and have static string id's that don't rely on %lang%.

This way you can use an if macro that will load the right text file depending on the output of %lang% and if you don't have text for a language it can default to French or English.

Offline rejetto

  • Administrator
  • Insane programmer
  • *
  • Posts: 12832
  • Country: it
    • View Profile
Re: tpl localisation
« Reply #11 on: December 16, 2007, 11:10:33 AM »
your suggestion will work bad when someone with a spanish browser access his HFS.

i think it would be good to be able to put the strings in an external file. the problem is that macros are executed at the end of the file list. so a {{load}} would be done too late.

in next build i will introduce a section [special:begin] where macros will be executed at the very first time.
in this section you could put {{load|strings-%lang%.txt}} and put your [special:string] inside that file.

Offline SilentPliz

  • Operator
  • Insane poster
  • *****
  • Posts: 1181
  • ....... chut ! shh!
    • View Profile
Re: tpl localisation
« Reply #12 on: December 16, 2007, 12:35:05 PM »
Thank you for your answers.

It helped me understand what you can do with these macros.

Olivier

Offline Foggy

  • Insane poster
  • *****
  • Posts: 806
    • View Profile
Re: tpl localisation
« Reply #13 on: December 26, 2007, 07:43:35 AM »
Would it be possible to include the [special:strings] section more then once in the template?

It would make the template allot more dynamic because I can load more then one file containing strings, It would be possible now to just include more then one load macro but the macro isn't evaluated before the symbol's table is made.

Offline rejetto

  • Administrator
  • Insane programmer
  • *
  • Posts: 12832
  • Country: it
    • View Profile
Re: tpl localisation
« Reply #14 on: December 26, 2007, 08:04:41 AM »
what you want to do?