[Include] translate.inc - Translating has never been easier!
#34

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?
Reply


Messages In This Thread
translate.inc - Translating has never been easier! - by Slice - 10.10.2013, 15:09
Re: translate.inc - Translating has never been easier! - by Konstantinos - 10.10.2013, 15:16
Re: translate.inc - Translating has never been easier! - by Champ - 10.10.2013, 15:17
Re: translate.inc - Translating has never been easier! - by IPrototypeI - 10.10.2013, 15:35
Re: translate.inc - Translating has never been easier! - by SsHady - 10.10.2013, 15:36
Re: translate.inc - Translating has never been easier! - by Michael@Belgium - 10.10.2013, 19:43
Re: translate.inc - Translating has never been easier! - by BloodMaster - 10.10.2013, 19:45
AW: translate.inc - Translating has never been easier! - by Mellnik - 10.10.2013, 19:59
Re: AW: translate.inc - Translating has never been easier! - by Slice - 10.10.2013, 20:24
Re: translate.inc - Translating has never been easier! - by iZN - 11.10.2013, 15:08
Re: translate.inc - Translating has never been easier! - by Matt - 12.10.2013, 23:45
Re: translate.inc - Translating has never been easier! - by Lorenc_ - 13.10.2013, 00:07
Re: translate.inc - Translating has never been easier! - by Slice - 13.10.2013, 00:12
Re: translate.inc - Translating has never been easier! - by Sublime - 13.10.2013, 01:28
Re: translate.inc - Translating has never been easier! - by Astralis - 13.10.2013, 08:39
Re: translate.inc - Translating has never been easier! - by Slice - 13.10.2013, 10:32
Re: translate.inc - Translating has never been easier! - by Excel™ - 13.10.2013, 15:14
Re: translate.inc - Translating has never been easier! - by Sublime - 14.10.2013, 02:53
Re: translate.inc - Translating has never been easier! - by shittt - 14.10.2013, 04:36
Re: translate.inc - Translating has never been easier! - by Slice - 14.10.2013, 06:17
Re: translate.inc - Translating has never been easier! - by Jay_ - 15.10.2013, 14:11
Re: translate.inc - Translating has never been easier! - by TheArcher - 15.10.2013, 18:52
Re: translate.inc - Translating has never been easier! - by Slice - 15.10.2013, 18:58
Re: translate.inc - Translating has never been easier! - by TheArcher - 15.10.2013, 19:01
Re: translate.inc - Translating has never been easier! - by AnonScripter - 12.01.2014, 22:00
Re: translate.inc - Translating has never been easier! - by TheArcher - 12.01.2014, 22:53
Re: translate.inc - Translating has never been easier! - by AnonScripter - 14.01.2014, 20:54
Re: translate.inc - Translating has never been easier! - by iZN - 15.01.2014, 07:12
Re: translate.inc - Translating has never been easier! - by LMagnifico - 15.01.2014, 08:22
Re: translate.inc - Translating has never been easier! - by Djole1337 - 14.06.2014, 13:30
Re: translate.inc - Translating has never been easier! - by Chilli9434 - 14.06.2014, 13:33
Re: translate.inc - Translating has never been easier! - by Segura - 21.07.2014, 14:27
Re: translate.inc - Translating has never been easier! - by CONTROLA - 04.04.2019, 08:48
Re: AW: translate.inc - Translating has never been easier! - by Sasino97 - 04.04.2019, 10:47
Re: translate.inc - Translating has never been easier! - by Variable™ - 04.04.2019, 11:45

Forum Jump:


Users browsing this thread: 1 Guest(s)