rejetto forum

Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: rejetto on December 08, 2007, 03:03:55 PM

Title: tpl localisation
Post by: rejetto on December 08, 2007, 03:03:55 PM
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.
Title: Re: tpl localisation
Post by: maverick on December 08, 2007, 03:12:10 PM

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?
Title: Re: tpl localisation
Post by: parade on December 08, 2007, 03:24:48 PM
Where do I find it on the keyboard?

ALT-156  ;)
Title: Re: tpl localisation
Post by: rejetto on December 08, 2007, 03:37:03 PM
ok, i guess we'll have to use a more international character, like # or ! ;)
Title: Re: tpl localisation
Post by: bacter on December 08, 2007, 04:29:10 PM
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.
Title: Re: tpl localisation
Post by: Mars on December 08, 2007, 06: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
Title: Re: tpl localisation
Post by: Foggy on December 09, 2007, 09: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&
Title: Re: tpl localisation
Post by: rejetto on December 09, 2007, 01:26:44 PM
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.
Title: Re: tpl localisation
Post by: rejetto on December 09, 2007, 01:34:12 PM
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.
Title: Re: tpl localisation
Post by: SilentPliz on December 16, 2007, 02:41:56 AM
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
Title: Re: tpl localisation
Post by: Foggy on December 16, 2007, 07: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.
Title: Re: tpl localisation
Post by: rejetto on December 16, 2007, 05:10:33 PM
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.
Title: Re: tpl localisation
Post by: SilentPliz on December 16, 2007, 06:35:05 PM
Thank you for your answers.

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

Olivier
Title: Re: tpl localisation
Post by: Foggy on December 26, 2007, 01:43:35 PM
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.
Title: Re: tpl localisation
Post by: rejetto on December 26, 2007, 02:04:41 PM
what you want to do?
Title: Re: tpl localisation
Post by: Foggy on December 27, 2007, 12:36:17 AM
basically, be able to load strings for [special:strings] from more then one file.

Edit: Just thought I'd try what I was asking and it worked but because you have to use {{load}} in [special:begin] at the top of the page the contents of the [special:string] sections that were loaded are displayed.

Edit2: Actually it didn't work, the special:strings were cached and a restart of hfs proved this. I'm trying to find the forum post (http://www.rejetto.com/forum/index.php?topic=5385.0) which explains about loading them from external files. Found the post and using Load from special:begin isnt working for me as I said above.
A picture can explain better than i can. PICTURE (http://users.on.net/~foggy2/Pics/load.JPG)
Title: Re: tpl localisation
Post by: rejetto on December 30, 2007, 02:36:03 AM
i may create a macro M (we'll decide the name later) that can handle string tables like these.

so you load any table
{{set|mytable|{{load|tablefile.txt}}/set}}

you can even append tables at later time
{{set|mytable|{{^mytable}} {{load|othertable.txt}}/set}}

and when you need a value from the table
{{M|mytable|key}}


opinions?
Title: Re: tpl localisation
Post by: Foggy on December 30, 2007, 08:20:47 AM
I like it, it will make it easier to use dynamic content becuase we would be able to load certain strings when a certain condition exists.
Title: Re: tpl localisation
Post by: rejetto on January 04, 2008, 08:41:27 PM
available from next beta
Title: Re: tpl localisation
Post by: Mars on January 04, 2008, 10:15:51 PM
Don't forget to add a macro with this possiblity

{{M|mytable| [sectionname] }}wich include all the section [sectionname]

this syntax  [...] is important to make difference with 'key'

{{M|mytable| [sectionname] }} or  {{M section|mytable|sectionname}}

 I know what rejetto will say to me :
"who needs this ?"

;D ;D ;D
Title: Re: tpl localisation
Post by: rejetto on January 05, 2008, 03:29:38 PM
the M macro has been called "from table".
as you guess, "from table" has nothing to do with the feature you asking.
moreover, it is already available since build #161. it is {{section|name|file}} but i forgot to document it. :)
Title: Re: tpl localisation
Post by: Foggy on January 17, 2008, 01:47:12 PM
is already available since build #161. it is {{section|name|file}} but i forgot to document it. :)

I just tried to use this and couldnt figure out how to. I ended up using set and from table instead.