Skip to content

Commit cfc9f37

Browse files
Merge pull request #883 from viachaslavic/new_translation
Update for adding new languages
2 parents 164203c + b1154b1 commit cfc9f37

File tree

1 file changed

+53
-13
lines changed

1 file changed

+53
-13
lines changed

docs/development/retroarch/new-translations.md

+53-13
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ While translation is handled via the Crowdin[^1] platform ([more here](new-trans
77
* `msg_hash.c`
88
* `msg_hash.h`
99
* `retroarch.c`
10+
* `translation_defines.h`
1011
* `intl/msg_hash_us.h`
1112
* `menu/menu_setting.c`
13+
* `tasks/task_translation.c`
1214
* `libretro-common/include/libretro.h`
1315

1416
> Every new language must first be added to the project on Crowdin. This will ensure that a corresponding `intl/msg_hash_xx.h` file is created. Requests are accepted at the `#retroarch-translations` channel of the RetroArch Discord[^2].
@@ -26,23 +28,18 @@ To add a language with the English name `XXXXX` and two-letter code `xx` (be sur
2628
2. Open `msg_hash.h`.
2729
1. Check if a `MENU_ENUM_LABEL_VALUE_LANG_XXXXX` item for your language is present in the `msg_hash_enums` enum; if not, add it.
2830
3. Open `msg_hash.c`.
29-
1. Add the following block inside the `msg_hash_get_help_enum(enum msg_hash_enums msg, char *s, size_t len)` function:
30-
```c
31-
case RETRO_LANGUAGE_XXXXX:
32-
break;
33-
```
34-
2. Add the following block inside the `get_user_language_iso639_1(bool limit)` function:
31+
1. Add the following block inside the `get_user_language_iso639_1(bool limit)` function:
3532
```c
3633
case RETRO_LANGUAGE_XXXXX:
3734
return "xx";
3835
```
39-
3. Add the following block inside the `msg_hash_to_str(enum msg_hash_enums msg)` function:
36+
2. Add the following block inside the `msg_hash_to_str(enum msg_hash_enums msg)` function:
4037
```c
4138
case RETRO_LANGUAGE_XXXXX:
42-
ret = msg_hash_to_str_xx(msg);
43-
break;
39+
ret = msg_hash_to_str_xx(msg);
40+
break;
4441
```
45-
4. Add a new static function:
42+
3. Add a new static function:
4643
```c
4744
static const char *msg_hash_to_str_xx(enum msg_hash_enums msg)
4845
{
@@ -66,15 +63,32 @@ MSG_HASH(
6663
)
6764
```
6865
6. Open `menu/menu_setting.c`.
69-
1. Add the following assignment to the `setting_get_string_representation_uint_user_language()` function:
66+
1. Add the following assignment to the `setting_get_string_representation_uint_user_language()` function, before `if (*msg_hash_get_uint(MSG_HASH_USER_LANGUAGE) == RETRO_LANGUAGE_ENGLISH)` statement:
7067
```c
71-
modes[RETRO_LANGUAGE_XXXXX] = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_LANG_XXXXX);
68+
LANG_DATA(XXXXX)
69+
```
70+
2. Add the following block inside the `setting_get_string_representation_uint_ai_service_lang()` function:
71+
```c
72+
case TRANSLATION_LANG_XX:
73+
enum_idx = MENU_ENUM_LABEL_VALUE_LANG_XXXXX;
74+
break;
7275
```
7376
7. Open `retroarch.c`.
74-
1. Add your language to `enum retro_language rarch_get_language_from_iso(const char *iso639)`:
77+
1. Add your language to `enum retro_language retroarch_get_language_from_iso(const char *iso639)`:
7578
```c
7679
{"xx", RETRO_LANGUAGE_XXXXX},
7780
```
81+
8. Open `tasks/task_translation.c`.
82+
1. Add the following block inside the `ai_service_get_str(enum translation_lang id)` function:
83+
```c
84+
case TRANSLATION_LANG_XX:
85+
return "xx";
86+
```
87+
9. Open `translation_defines.h`.
88+
1. Add your language to the `translation_lang` enum between `TRANSLATION_LANG_DONT_CARE` and `TRANSLATION_LANG_LAST`items:
89+
```c
90+
TRANSLATION_LANG_XX, /* Xxxxx */
91+
```
7892

7993
## Optional Adjustments
8094

@@ -172,6 +186,30 @@ To do that for cores which have been added to Crowdin, follow these steps:
172186

173187
> Adding cores to Crowdin is a whole other elaborate process and, currently, can only be performed by a Crowdin manager. Suggestions/Requests can be submitted on Discord to DisasterMo#0389.
174188
189+
### Narrator support
190+
191+
1. For Mac. (compatible with **say**)
192+
1. Open `frontend/drivers/platform_darwin.m`.
193+
2. Go to `accessibility_mac_language_code(const char* language)` function. Check if the following block is present, where `Yyyyy` is the voice name for the language and if not, add it before `return ""`:
194+
```c
195+
else if (string_is_equal(language,"xx"))
196+
return "Yyyyy";
197+
```
198+
2. For Linux. (compatible with **[espeak](https://github.com/espeak-ng/espeak-ng)**)
199+
1. Open `frontend/drivers/platform_unix.c`.
200+
2. Go to `accessibility_unix_language_code(const char* language)` function. Check if the following block is present, where `yyy` is the [Identifier](https://github.com/espeak-ng/espeak-ng/blob/master/docs/languages.md) for the language and if not, add it before `/* default voice as fallback */`:
201+
```c
202+
else if (string_is_equal(language, "xx"))
203+
return "yyy";
204+
```
205+
3. For Windows. (OS compatiable)
206+
1. Open `frontend/drivers/platform_win32.c`.
207+
2. Go to `accessibility_win_language_code(const char* language)` function. Check if the following block is present, where `Yyyyy` is the [voice name](https://support.microsoft.com/en-us/windows/appendix-a-supported-languages-and-voices-4486e345-7730-53da-fcfe-55cc64300f01#WindowsVersion=Windows_10) for the language and if not, add it before `return ""`:
208+
```c
209+
else if (string_is_equal(language,"xx"))
210+
return "Microsoft Yyyyy Desktop";
211+
```
212+
175213
## Encoding of translation files
176214

177215
Translation files (`intl/msg_hash_xx.h`) in general must be UTF-8 encoded.
@@ -200,6 +238,8 @@ Be careful when creating and editing your new translation files, as some text ed
200238
* Indonesian, Swedish and Ukrainian (+RGUI):
201239
* [Add Indonesian, Swedish and Ukrainian language options](https://github.com/libretro/RetroArch/commit/311fec15d9db10ab14c879e898a8205dd37f827c)
202240

241+
* [List of merges related to adding languages](https://github.com/libretro/RetroArch/pulls?q=is%3Apr+is%3Amerged+in%3Atitle+add+language+option+)
242+
203243
### Enabling new languages for cores
204244

205245
* mgba:

0 commit comments

Comments
 (0)