- script pick_language -1,{ // This serves as a basic language picker, but will not be very useful
OnPCLoginEvent:
function i18n; // i18n is short for internacionalization
if (language) end; // People who have chosen a language don't need to use this NPC, other will fall through
OnWhisperGlobal: //This way people can change their language at any time, even if this makes this code messy
do {
mes i18n(5);
mes i18n(6);
mes i18n(7);
mes i18n(8);
set language, prompt(i18n(1)+":"+i18n(2)+":"+i18n(3)+":"+i18n(4)); // Chosen option will be user's language ID
} while (@menu == 255); // Force user to pick one of the available languages
close;
function i18n { // Each NPC will have its own i18n function. This one is quite simple.
switch(getarg(0)) {
case 1: return "English";
case 2: return "Français (French)";
case 3: return "Español (Spanish)";
case 4: return "Deutsch (German)";
case 5: return "Please choose a language"; // English
case 6: return "Veuillez choisir une langue s'il vous plaît"; // French
case 7: return "Por favor, elige un idioma"; // Spanish
case 8: return "Bitte Sprache auswählen"; // German
default: return "Unknown message string ID";
}
/* Alternate version: this one is faster but it's a bit harder to understand
setarray .@i18n[1]$, // Maybe this array should better be set OnInit with a permanent NPC variable, but it's just an example
// In that case, just the return sentence is needed
"English",
"Français (French)",
"Español (Spanish)",
"Deutsch (German)",
"Please choose a language", // English
"Veuillez choisir une langue s'il vous plaît", // French
"Por favor, elige un idioma", // Spanish
"Bitte Sprache auswählen"; // German
set .@numStrings, getarraysize(.@i18n$);
return getarg(0) < .@numStrings ? .@i18n[getarg(0)] : "Unknown message string ID";
*/
}
}
map,x,y script language_tester 60,{ // You can use this when you have your language defined, a bit more complex but easier at the same time
function i18n;
set @times, @times+1;
mes i18n(language,1);
mes i18n(language,2) + @times + i18n(language,4); // i18n(language,2) has a trailing space, and i18n(language,3) has a leading space
close;
function i18n {
switch(getarg(0)) { // Languages
case 1: // English
switch(getarg(1)) { // Strings
case 1: return "This is a language test script.";
case 2: return "You've clicked me ";
case 3: return " times since you logged in.";
default: return "String Error";
} // Supposedly no break needed
case 2: // French
switch(getarg(1)) {
case 1: return "Ç'est un script de teste de langue.";
case 2: return "Vous m'avez cliqué ";
case 3: return " fois depuis vous êtes online.";
default: return "Ereur de string";
}
case 3: // Spanish
switch(getarg(1)) {
case 1: return "Esto es un script de prueba de idiomas.";
case 2: return "Me has hecho click ";
case 3: return " veces desde que te has conectado.";
default: return "Error de string";
}
case 4: // German
switch(getarg(1)) {
case 1: return "Die ist ein Sprachen Test NPC.";
case 2: return "Du hast mich ";
case 3: return " mal angeklickt seit du online bist.";
default: return "String Fehler";
}
default: // Language error
return "Language error!";
}
// You could also do something similar: you store an array of array names, then fetch the desired position on that array if you do like that.
}
}