Sie sind nicht angemeldet.

1

Freitag, 8. März 2013, 04:50

TIP for using DUAL LANGUAGES (or MULTIPLE)

This may seem trivial to some of our more seasoned programmers here, which I don't really claim to be one at all, but I came up with a fairly simple and effective method for changing languages globally using the textfield and thought I would share.

1) ADD language attributes to all of the textfield plugins which require dual or multilanguage text. Be sure to ADD 1 attribute per language and give it a name to reference the language data set you create with reference to the current plugin. You can leave the html field blank at this point.
Example:

Quellcode

1
2
3
4
5
<plugin name="thisPlugin" 
engData="data:thisPlugin_eng"
thaiData="data:thisPlugin_thai"
html=""
/>


2) Create the text data sets to contain all of the language data (note: each plugin will have a SET based on the # of language attributes added to the plugin.
Example:

Quellcode

1
2
3
<!-- for the Plugin : "thisPlugin" -->
<data name="thisPlugin_eng"> Some English Text </data>
<data name="thisPlugin_thai"> Some Thai Text </data>


3) Add a variable for the current language and call an action to change the language on startup (and on the language buttons too!)
Example:

Quellcode

1
set(curlang, eng); changlang();


4) Use an FOR action to check ALL plugins, and find any that have had a language attribute added to them.
Example:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<action name="changlang">
for(
	set(i,0), 
		i LT plugin.count, 
			inc(i), 
				
if(plugin[get(i)].engdata,

	set(curplugin, get(plugin[get(i)].name));

	if(curlang == eng,
		set(plugin[get(curplugin)].html, get(plugin[get(curplugin)].engdata));
		,
		set(plugin[get(curplugin)].html, get(plugin[get(curplugin)].thaidata));
	);

);
);
</action>


The above example is for dual language. Multi-language you can simply change the if statements to include the other languages...
if(curlang == eng...
if(curlang == thai...
if(curlang == ger
etc....

Hope this helps. Just wanted to give back to the community.

If you know a simpler way... I'm all eyes.

Tony