Quote:
Originally Posted by Slice
It allows you to have your script in multiple languages. Say you have one spanish guy, one russian, and one canadian - this script will allow you to send messages in each respective language to them.
Normal translation scripts usually do something like define variables such as LANG_HELLO then give them values in language files ("hola", "privet", "hello").
That can get rather confusing, because the language string is not in your code - you have to look it up every time. Furthermore, you don't know what format specifiers are in it (%s, %d, etc.).
Other includes:
pawn Код:
[russian] LANG_HELLO = "privet" LANG_GIVEN_WEAPON = "vodka vodka %s na zdorovye %s." [spanish] LANG_HELLO = "hola" LANG_GIVEN_WEAPON = "tengo much armas %s y %s." [english] LANG_HELLO = "hello" LANG_GIVEN_WEAPON = "You were given a %s by %s."
pawn Код:
SendClientMessage(playerid, color, GetText(LANG_HELLO, playerid)); SendClientMessage(playerid, color, sprintf(GetText(LANG_GIVEN_WEAPON, playerid), weapon, name));
This include:
pawn Код:
// russian.lang.inc "hello" = "privet" "You were given a %s by %s." = "vodka vodka %s na zdorovye %s." // spanish.lang.inc "hello" = "hola" "You were given a %s by %s." = "tengo much armas %s y %s."
pawn Код:
SendClientMessage(playerid, color, __("hello", playerid)); SendClientMessage(playerid, color, sprintf(__("You were given a %s by %s.", playerid), weapon, name));
|
I don't agree with this method. This means that you must have the exact same string both in the language file and in code. Let's suppose that you add a single character to your message in code, like an exclamation point, then you must remember to edit the language file otherwise the translation won't work.
For this reason, I think that ******'s localization system, which is basically the same system used in many other frameworks (such as Android and WPF), is a much better option.
Quote:
"vodka vodka %s na zdorovye %s."
"tengo much armas %s y %s."
|
lol?