summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--npc/commands/language.txt23
-rw-r--r--npc/functions/asklanguage.txt15
2 files changed, 38 insertions, 0 deletions
diff --git a/npc/commands/language.txt b/npc/commands/language.txt
index a03e2cf70..24cc07feb 100644
--- a/npc/commands/language.txt
+++ b/npc/commands/language.txt
@@ -31,7 +31,30 @@ OnCall:
CMD_lang();
close;
+OnTranslate:
+ // Implode, using a slash at whitespaces
+ .@request$ = implode(.@atcmd_parameters$, "%2F");
+ // No NPC provided?
+ if (.@request$ == "") {
+ dispbottom l("Usage: @translate <npc file>");
+ dispbottom l("Example: @translate Nard");
+ dispbottom l("Example: @translate Elmo");
+ dispbottom l("Example: @translate npc/002-1/arpan");
+ dispbottom l("PS. Doesn't always work. You need an account at %s", "@@https://www.transifex.com/akaras|Transifex@@ and to be at ManaPlus Team.");
+ end;
+ }
+ // Add .txt extension of needed
+ if (!compare(.@request$, ".txt")
+ .@request$ += ".txt"
+ // Fix stuff for URL format
+ .@request$ = replacestr(.@request$, "/", "%2F");
+ .@request$ = strtolower(.@request$);
+ // Give your translation link
+ dispbottom "@@https://www.transifex.com/akaras/saulc-tmw-fork/translate/#"+languagecode()+"/server-data?q=occurrence%3A"+.@request$+"|Translate with Transifex@@";
+ close;
+
OnInit:
bindatcmd "lang", "@lang::OnCall", 0, 60, 0;
+ bindatcmd "translate", "@lang::OnTranslate", 0, 60, 0;
end;
}
diff --git a/npc/functions/asklanguage.txt b/npc/functions/asklanguage.txt
index 3782e5316..d10f5534f 100644
--- a/npc/functions/asklanguage.txt
+++ b/npc/functions/asklanguage.txt
@@ -5,6 +5,21 @@
// Description:
// Function setting the player language
+function script languagecode {
+ switch (Lang) {
+ case LANG_PTBR:
+ return "pt-BR";
+ case LANG_FR:
+ return "fr";
+ case LANG_DE:
+ return "de";
+ case LANG_ES:
+ return "es";
+ default:
+ return "en";
+ }
+}
+
function script asklanguage {
switch (getarg(0, LANG_IN_SHIP))