rejetto forum

Macros

Mars · 231 · 81799

0 Members and 1 Guest are viewing this topic.

Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
I'am still having problems with localization.

In the maintemplate i have
Quote
[special:begin]
{{load|bts_init.tpl}} {{comment|global vars, origin of request,force browserlang to availablelang(+selectedlang)->userlang}}
{{load|btslang_{{^userlang}}.tpl|special:string}}
[special:strings]
lfile=Languagefile in template
lfmodif=20080128
....

With build #177 this should work, but {{!lfile}} etc. return the values from [special:strings] and not from the vars loaded into 'special:string' from the file. ┬┐What am I doing wrong to get it working?
your computer has no brain - use your own !


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 1985
    • View Profile
{{load|btslang_{{^userlang}}.tpl|special:string}}


modify to {{load|btslang_{{^userlang}}.tpl|special:strings}}


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1934
    • View Profile
    • RAWR-Designs
Might only be a bug in 178beta but i cant get the strings to go to all the other pages in the template. It only works for the main section of it.

This is my macro. The contents of the file works fine if i paste it in the tpl, but the load macro should work for localisation to be complete.
(i think in my version the load macro can use URI's for links so that isn't the bug)

[special:begin]
{{load|/template/rawr_default/languages/en.txt|special:strings}}


Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
are the other pages user defined sections? if so, try placing {{$special:begin}} at the top of the section.


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1934
    • View Profile
    • RAWR-Designs
Thanks that works, but I think assigning the load to special:strings should also make it a global var.
« Last Edit: January 30, 2008, 08:32:52 AM by That_Stevens_Guy »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13260
    • View Profile
ok, added
i hope you truly need these macros, because we must add only the macros we use


Offline Foggy

  • Tireless poster
  • ****
    • Posts: 806
    • View Profile
when I use {{?var}} is it possible that if there isn't a url variable with that name that it then checks for a postvar with that name.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13260
    • View Profile
i don't know if it would be a good idea.
for sure i can make a {{urlpostvar}} macro.
otherwise we can discuss having ? as urlpostvar, and not as alias of urlvar.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 1985
    • View Profile
As there is not much again at the moment, it will be just small craftiness to put something itself under the tooth


when you find in your template

{{if|{{%bread-name%=}}|Home|%bread-name%}}

You can replace it by

{{or|%bread-name%|Home}}

Reminder: the macro {{OR|...}} sends back the first non-empty parameter

« Last Edit: February 24, 2008, 10:09:44 PM by mars »


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1934
    • View Profile
    • RAWR-Designs
RAWR-Template already uses this and rejetto gave me that code :P guess he forgot to update his own.

The default template needs a fair bit of work, I could make it w3c web standard and better written within a nights work. It is quite bad at the moment. It uses xhtml yet doesn't follow many of the xhtml rules :P

{{breadcrumbs|{{\<a href="%bread-url%">{{or|%bread-name%|{{!lv_home}}}}/</a>/}}}}

Macro suggestion, {{encodeURI| }} {{decodeURI|}} {{escape|}} {{unescape|}}. I thought they were already suggested/implemented but they arent. Possible uses include encoding certain strings for use with flash applets, or just simply doing what the uses for these are in javascript/actionscript etc.

Lastly, is there a way to detect odd and even numbers, or a macro that could do such a job? I am interested to do this to implement alternate row colour into RAWR-Template.
« Last Edit: February 25, 2008, 06:02:25 PM by That_Stevens_Guy »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13260
    • View Profile
by using {{or}} for such purpose, it will consider "empty" folders with name "0" and "false".

{{mod|%number%|2}} will tell you if a number is odd. even with a {{not}}


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13260
    • View Profile
Macro suggestion, {{encodeURI| }} {{decodeURI|}} {{escape|}} {{unescape|}}.

could you please specify what they are supposed to do?
you can point me to an equivalent javascript function, if any.


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1934
    • View Profile
    • RAWR-Designs
ok,

http://www.w3schools.com/jsref/jsref_encodeURI.asp
http://www.w3schools.com/jsref/jsref_escape.asp

I use them alot but this explains it nicely.

And I do not know if it is possible... But it would be awesome to have one that converts special characters to their ascii or hex equivalent.
&nbsp; &amp; etc. But i don't think there is a defined function for it.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 1985
    • View Profile
by waiting

{{set|encodeURI| {{\ replace | < | %3C | >| %3E | { | %7B | [ | %5B | ] | %5D| } | %7D | ....|$1}} /}} }}
{{set|decodeURI| {{\ replace | %3C | < | %3E| > | %7B| { | %5B  | [ | %5D| ] | %7D| }  | ....|$1}} /}} }}


{{^encodeURI | text }}


Offline Andrew-Sirius

  • Occasional poster
  • *
    • Posts: 16
    • View Profile
Hi!

How it is possible with the aid of the macro to verify the presence of file in the folder?
For example about.html

And if file is present, then carry out one action, but if it does not exist, then carry out another action.