Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation feature #1

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Thumbs.db
/config.status
/core
/ipch
/lang/*
/login-server
/Makefile
/Makefile.cache
Expand Down
39 changes: 39 additions & 0 deletions conf/languages.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//===== rAthena Configuration File ===========================
//
// Translations generated with '�-generate-translations' should be pointed to here
//============================================================

// When employing more than one language, this setting is used as a fallback.
default_language: "English"

// List of languages.
languages: {
//===== Structure ============================================
//
//LanguageName: { // Name of language, used for looking up user's language on @langtype.
// lang: ( // List of translations file(s) for NPC Script dialogs,
// "path/to/translation.po", // use comma (,) to separated next file, don't forget the quotes, and
// "path/to/translation2a.po // DO NOT use comma (,) for last file.
// )
// motd: "path/to/motd.file" // For MOTD file, alternative conf/motd.txt for this language. TODO: Use PO.
// help: "path/to/help.file" // For @Help file, alternative conf/help.txt for this language. TODO: Use PO.
//}
//============================================================
// Examples:
//
//Spanish: {
// lang: (
// "lang/Spanish.po"
// )
//}
//Indonesian: {
// motd: "lang/Indonesian/motd.txt"
// help: "lang/Indonesian/help.txt"
// lang: (
// "lang/Indonesian/msg_conf.po",
// "lang/Indonesian/npc/airports/airship.po",
// "lang/Indonesian/npc/re/cities/malangdo.po",
// "lang/Indonesian/npc/re/jobs/novice/novice.po"
// )
//}
}
3 changes: 3 additions & 0 deletions conf/map_athena.conf
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ help_txt: conf/help.txt
help2_txt: conf/help2.txt
charhelp_txt: conf/charhelp.txt

// Translation file
language_conf: conf/languages.conf

// Maps:
import: conf/maps_athena.conf

Expand Down
22 changes: 11 additions & 11 deletions conf/msg_conf/map_msg.conf
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@
900: Usage:
901: @send len <packet hex number>
902: @send <packet hex number> {<value>}*
903: Value: <type=B(default),W,L><number> or S<length>"<string>"
903: Value: <type=B(default),W,L><number> or S<length>\"<string>\"
904: Packet 0x%x length: %d
905: Unknown packet: 0x%x
906: Not a string:
Expand Down Expand Up @@ -1169,8 +1169,8 @@
1193: You're currently not autolooting this item.
1194: Removed item: '%s'/'%s' {%hu} from your autolootitem list.
1195: You can have %d items on your autolootitem list.
1196: To add an item to the list, use "@alootid +<item name or ID>". To remove an item, use "@alootid -<item name or ID>".
1197: "@alootid reset" will clear your autolootitem list.
1196: To add an item to the list, use \"@alootid +<item name or ID>\". To remove an item, use \"@alootid -<item name or ID>\".
1197: \"@alootid reset\" will clear your autolootitem list.
1198: Your autolootitem list is empty.
1199: Items on your autolootitem list:
1200: Your autolootitem list has been reset.
Expand Down Expand Up @@ -1375,8 +1375,8 @@

// @mapflag
1311: Enabled Mapflags in this map:
1312: Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
1313: Type "@mapflag available" to list the available mapflags.
1312: Usage: \"@mapflag monster_noteleport 1\" (0=Off | 1=On)
1313: Type \"@mapflag available\" to list the available mapflags.
1314: Invalid flag name or flag.
1315: Available Flags:

Expand Down Expand Up @@ -1455,13 +1455,13 @@

// @accinfo
1365: Usage: @accinfo/@accountinfo <account_id/char name>
1366: You may search partial name by making use of '%' in the search, ex. "@accinfo %Mario%" lists all characters whose name contains "Mario".
1366: You may search partial name by making use of '%' in the search, ex. \"@accinfo %Mario%\" lists all characters whose name contains \"Mario\".

// @set
1367: Usage: @set <variable name> <value>
1368: Usage: ex. "@set PoringCharVar 50"
1369: Usage: ex. "@set PoringCharVarSTR$ Super Duper String"
1370: Usage: ex. "@set PoringCharVarSTR$" outputs its value, Super Duper String.
1368: Usage: ex. \"@set PoringCharVar 50\"
1369: Usage: ex. \"@set PoringCharVarSTR$ Super Duper String\"
1370: Usage: ex. \"@set PoringCharVarSTR$\" outputs its value, Super Duper String.
1371: NPC variables may not be used with @set.
1372: Instance variables may not be used with @set.
1373: %s value is now: %d
Expand Down Expand Up @@ -1603,9 +1603,9 @@
1483: Autolooting item type: '%s' {%d}
1484: You're currently not autolooting this item type.
1485: Removed item type: '%s' {%d} from your autoloottype list.
1486: To add an item type to the list, use "@aloottype +<type name or ID>". To remove an item type, use "@aloottype -<type name or ID>".
1486: To add an item type to the list, use \"@aloottype +<type name or ID>\". To remove an item type, use \"@aloottype -<type name or ID>\".
1487: Type List: healing = 0, usable = 2, etc = 3, armor = 4, weapon = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10
1488: "@aloottype reset" will clear your autoloottype list.
1488: \"@aloottype reset\" will clear your autoloottype list.
1489: Your autoloottype list is empty.
1490: Item types on your autoloottype list:
1491: Your autoloottype list has been reset.
Expand Down
113 changes: 113 additions & 0 deletions lang/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# rAthena Language Library
=========

### Table of Contents
---------
1. Generating Translation (.pot) File
2. Translating Language (.po) File
3. Adding New Language
4. Set Default Language
5. Change Language
6. Other Translation
7. Contributing
8. Known Translation Project

## 1. Generating Translation (.pot) File
---------
Please makes sure map-server was compiled.
### Windows:
````
map-server.exe --generate-translations [path/to/generated.file]
````
### Linux:
````
map-server --generate-translations [path/to/generated.file]
````

## 2. Translating Language (.po) File
---------
* After generating the translation/template .pot file, rename it to "My_Translation.po"
* Open the file, then try find this dialog.
````
#: npc/re/jobs/novice/novice.txt
# mes "Hello there! Welcome to the World of Ragnarok Online. My name is Sprakki and I'm in charge of giving you basic gameplay tips.";
msgctxt "Sprakki#newbe01::NvSprakkiA"
msgid "Hello there! Welcome to the World of Ragnarok Online. My name is Sprakki and I'm in charge of giving you basic gameplay tips."
msgstr ""
````
* Add/edit the dialog inside `msgstr ""` (Example in Indonesian from idRO)
````
#: npc/re/jobs/novice/novice.txt
# mes "Hello there! Welcome to the World of Ragnarok Online. My name is Sprakki and I'm in charge of giving you basic gameplay tips.";
msgctxt "Sprakki#newbe01::NvSprakkiA"
msgid "Hello there! Welcome to the World of Ragnarok Online. My name is Sprakki and I'm in charge of giving you basic gameplay tips."
msgstr "Halo! Selamat datang di Ragnarok Online Indonesia. Namaku adalah Sprakki dan aku disini untuk membantumu mengenai pengetahuan dasar bermain."
````
* Save the file.
* Make sure the EOL as UNIX.

**NOTE:** Steps above are translating manual using text editor.

## 3. Adding New Language
---------
1. Open conf/translation.conf
2. Add your language name and the file for translations.
````
My_Language: { // Langauge Name
lang: (
"lang/My_Translation.po" // Translation file
)
}
````

Notes:
* More than 1 language can be added
* More than 1 file can be listed for a language, use comma to separated the file pathname.


## 4. Set Default Language
---------
1. Before changing default language, amke sure the language is added.
2. Change the default language value in
````
default_language: "My_Language"
````


## 5. Change Language
---------
Use **`@langtype`** in-game. Example: `@langtype My_Language`.
The language changed will be stored stored as player's account variable.


## 6. Other Translation
---------
Besides NPC dialogs, translation is also available for:
* Atcommand messages (since multilanguage of msg_conf was depreciated).
* Atcommand Help message (`@help`)
* Message of The Day (MoTD)
````
translations: {
My_Language: { // Langauge Name
motd: "lang/Indonesian/motd.txt" // MOTD Translation
help: "lang/Indonesian/help.txt" // Help Translation
lang: (
"lang/My_Translation/msg_conf.po" // map_athena.conf Translation
)
}
}
````

## 7. Contributing
---------
* rAthena **DOES NOT** officially manage the translation files. Please contact respective community that provide translation project.
* rAthena **ONLY** will lists the translation project that fit our regulations.
* Try visit [rAthena International Forums](https://rathena.org/board/forum/6-international-forums/) to dig informations.
* Credits:
* Originally by [@HerculesWS](https://github.com/HerculesWS) on https://github.com/HerculesWS/Hercules/commit/330e31cc71ece055908acb1eb967b4009ebc9c46.
* [@aleos89](https://github.com/aleos89), adapted to [@rAthena](https://github.com/rAthena).
* [@cydh](https://github.com/cydh), restructured.

## 8. Known Translation Project
---------
* *No informations yet*
15 changes: 15 additions & 0 deletions src/common/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "showmsg.h"
#include "core.h"
#include "cli.h"
#include "malloc.h"

//map confs
char* MAP_CONF_NAME;
Expand All @@ -37,6 +38,8 @@ char* LOGIN_CONF_NAME;
//common conf (used by multiple serv)
char* LAN_CONF_NAME; //char-login
char* MSG_CONF_NAME_EN; //all
char* TRANSLATION_CONF_FILE;
char *lang_export_file;

/**
* Function to check if the specified option has an argument following it.
Expand All @@ -56,6 +59,12 @@ bool opt_has_next_value(const char* option, int i, int argc){
return true;
}

bool opt_has_next_value_(const char* option, int i, int argc){
if (i >= argc - 1)
return false;
return true;
}

/**
* Display some information about the emulator, such as:
* svn version
Expand Down Expand Up @@ -171,6 +180,12 @@ int cli_get_options(int argc, char ** argv) {
else if (strcmp(arg, "log-config") == 0) {
if (opt_has_next_value(arg, i, argc))
LOG_CONF_NAME = argv[++i];
} else if (strcmp(arg, "generate-translations") == 0) {
if (opt_has_next_value_(arg, i, argc))
lang_export_file = aStrdup(argv[++i]);
else
lang_export_file = aStrdup("./lang/generated_translations.pot");
runflag = CORE_ST_STOP;
}
else {
ShowError("Unknown option '%s'.\n", argv[i]);
Expand Down
3 changes: 3 additions & 0 deletions src/common/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ extern "C" {
extern char* ATCOMMAND_CONF_FILENAME;
extern char* SCRIPT_CONF_NAME;
extern char* GRF_PATH_FILENAME;
// Set during startup when attempting to export the lang, unset after server initialization is over
extern char *lang_export_file; // for lang_export_fp
//char
extern char* CHAR_CONF_NAME;
extern char* SQL_CONF_NAME;
Expand All @@ -37,6 +39,7 @@ extern void display_helpscreen(bool exit);
bool cli_hasevent();
void display_versionscreen(bool do_exit);
bool opt_has_next_value(const char* option, int i, int argc);
bool opt_has_next_value_(const char* option, int i, int argc);
int cli_get_options(int argc, char ** argv);
int parse_console_timer(int tid, unsigned int tick, int id, intptr_t data);
extern int parse_console(const char* buf); //particular for each serv
Expand Down
Loading