Skip to content

Commit

Permalink
Merge pull request #883 from viachaslavic/new_translation
Browse files Browse the repository at this point in the history
Update for adding new languages
  • Loading branch information
LibretroAdmin authored Mar 21, 2024
2 parents 164203c + b1154b1 commit cfc9f37
Showing 1 changed file with 53 additions and 13 deletions.
66 changes: 53 additions & 13 deletions docs/development/retroarch/new-translations.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ While translation is handled via the Crowdin[^1] platform ([more here](new-trans
* `msg_hash.c`
* `msg_hash.h`
* `retroarch.c`
* `translation_defines.h`
* `intl/msg_hash_us.h`
* `menu/menu_setting.c`
* `tasks/task_translation.c`
* `libretro-common/include/libretro.h`

> 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].
Expand All @@ -26,23 +28,18 @@ To add a language with the English name `XXXXX` and two-letter code `xx` (be sur
2. Open `msg_hash.h`.
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.
3. Open `msg_hash.c`.
1. Add the following block inside the `msg_hash_get_help_enum(enum msg_hash_enums msg, char *s, size_t len)` function:
```c
case RETRO_LANGUAGE_XXXXX:
break;
```
2. Add the following block inside the `get_user_language_iso639_1(bool limit)` function:
1. Add the following block inside the `get_user_language_iso639_1(bool limit)` function:
```c
case RETRO_LANGUAGE_XXXXX:
return "xx";
```
3. Add the following block inside the `msg_hash_to_str(enum msg_hash_enums msg)` function:
2. Add the following block inside the `msg_hash_to_str(enum msg_hash_enums msg)` function:
```c
case RETRO_LANGUAGE_XXXXX:
ret = msg_hash_to_str_xx(msg);
break;
ret = msg_hash_to_str_xx(msg);
break;
```
4. Add a new static function:
3. Add a new static function:
```c
static const char *msg_hash_to_str_xx(enum msg_hash_enums msg)
{
Expand All @@ -66,15 +63,32 @@ MSG_HASH(
)
```
6. Open `menu/menu_setting.c`.
1. Add the following assignment to the `setting_get_string_representation_uint_user_language()` function:
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:
```c
modes[RETRO_LANGUAGE_XXXXX] = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_LANG_XXXXX);
LANG_DATA(XXXXX)
```
2. Add the following block inside the `setting_get_string_representation_uint_ai_service_lang()` function:
```c
case TRANSLATION_LANG_XX:
enum_idx = MENU_ENUM_LABEL_VALUE_LANG_XXXXX;
break;
```
7. Open `retroarch.c`.
1. Add your language to `enum retro_language rarch_get_language_from_iso(const char *iso639)`:
1. Add your language to `enum retro_language retroarch_get_language_from_iso(const char *iso639)`:
```c
{"xx", RETRO_LANGUAGE_XXXXX},
```
8. Open `tasks/task_translation.c`.
1. Add the following block inside the `ai_service_get_str(enum translation_lang id)` function:
```c
case TRANSLATION_LANG_XX:
return "xx";
```
9. Open `translation_defines.h`.
1. Add your language to the `translation_lang` enum between `TRANSLATION_LANG_DONT_CARE` and `TRANSLATION_LANG_LAST`items:
```c
TRANSLATION_LANG_XX, /* Xxxxx */
```

## Optional Adjustments

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

> 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.
### Narrator support

1. For Mac. (compatible with **say**)
1. Open `frontend/drivers/platform_darwin.m`.
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 ""`:
```c
else if (string_is_equal(language,"xx"))
return "Yyyyy";
```
2. For Linux. (compatible with **[espeak](https://github.com/espeak-ng/espeak-ng)**)
1. Open `frontend/drivers/platform_unix.c`.
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 */`:
```c
else if (string_is_equal(language, "xx"))
return "yyy";
```
3. For Windows. (OS compatiable)
1. Open `frontend/drivers/platform_win32.c`.
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 ""`:
```c
else if (string_is_equal(language,"xx"))
return "Microsoft Yyyyy Desktop";
```

## Encoding of translation files

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

* [List of merges related to adding languages](https://github.com/libretro/RetroArch/pulls?q=is%3Apr+is%3Amerged+in%3Atitle+add+language+option+)

### Enabling new languages for cores

* mgba:
Expand Down

0 comments on commit cfc9f37

Please sign in to comment.