PDA

View Full Version : to make the script multi-language


xiaodao
04-03-2005, 04:14 AM
how to do that :confused:

xiaodao
04-03-2005, 04:33 AM
is this effective?
first, i create an array

$lang=array (
title=>"welcome",
);

then include this array, the problem is because i am using smarty template system, this array may appears big, i must assign this array to every template file, even only a part of the array is used, how to make it effecient?

Sicton
04-03-2005, 04:58 AM
A lot of scripts have language files which have a long list of language variables which are stored in an array e.g.

file: languages/en-uk.php

$lang['Welcome'] = 'Welcome';

file: languages/de.php

$lang['Welcome'] = 'Empfang';

According to what language you want to display, you then include a particular language file before running your code.

Then if you were outputting something simple, it would be in the selected language e.g

echo $lang['Welcome']; // would display in English if English language pack was loaded or in German if German pack loaded etc.

xiaodao
04-03-2005, 05:06 AM
hi, thanks, for you method, if i am using template system, should i assign the language variable one by one to templates?

Sicton
04-03-2005, 05:09 AM
If you're replacing text you've written in templates that you want to be displayed in another language, if I understand correctly, yes, you'll have to replace those pieces of text with the new language variables so they change according the the language.

xiaodao
04-03-2005, 05:14 AM
thanks.

Sicton
04-03-2005, 05:16 AM
No problem; I hope it works for you and I've understood you correctly :)

Good luck!