rejetto forum

tpl localisation

rejetto · 22 · 18773

0 Members and 1 Guest are viewing this topic.

Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
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

  • Tireless poster
  • ****
    • Posts: 1052
  • Computer Solutions
    • View Profile

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 rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
ok, i guess we'll have to use a more international character, like # or ! ;)


Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
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
  • Tireless poster
  • *****
    • Posts: 2063
    • View Profile
 
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, 01:28:00 PM by rejetto »


Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
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
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
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, 01:32:55 PM by rejetto »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
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
  • Tireless poster
  • *****
    • Posts: 1298
  • ....... chut ! shh!
    • View Profile
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 16, 2007, 04:11:04 AM by SilentPliz »


Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
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
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
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
  • Tireless poster
  • *****
    • Posts: 1298
  • ....... chut ! shh!
    • View Profile
Thank you for your answers.

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

Olivier


Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
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
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile