Adding a translation to a new language¶
Files you need to change¶
libretro-common/include/libretro.h
msg_hash.h
msg_hash.c
Makefile.common
intl/msg_hash_xx.c
(new file)intl/msg_hash_xx.h
(new file)intl/msg_hash_us.h
menu/menu_setting.c
griffin/griffin.c
Instructions¶
- Open
libretro-common/include/libretro.h
- Add a
RETRO_LANGUAGE_XXXXX
item to theretro_language
enum just aboveRETRO_LANGUAGE_LAST
, using the next available integer value - Open
msg_hash.h
- Add a
MENU_ENUM_LABEL_VALUE_LANG_XXXXX
item to themsg_hash_enums
enum - Add declaration of a
const char *msg_hash_to_str_xx(enum msg_hash_enums msg)
function - Add declaration of a
int menu_hash_get_help_xx_enum(enum msg_hash_enums msg, char *s, size_t len)
function - Open
msg_hash.c
- Add a
case RETRO_LANGUAGE_XXXXX: ret = menu_hash_get_help_xx_enum(msg, s, len); break;
block inside themenu_hash_get_help_enum()
function - Add a
case RETRO_LANGUAGE_XXXXX: ret = msg_hash_to_str_xx(msg); break;
block inside themsg_hash_to_str()
function - Open
Makefile.common
- Add
intl/msg_hash_xx.o
toOBJS
- Copy
intl/msg_hash_us.c
tointl/msg_hash_xx.c
- Decide if
intl/msg_hash_xx.c
should use UTF-8 + BOM encoding. See the section below - Open
intl/msg_hash_xx.c
- Rename the
menu_hash_get_help_us_enum()
function tomenu_hash_get_help_xx_enum()
- Rename the
menu_hash_to_str_us_label_enum()
function tomenu_hash_to_str_xx_label_enum()
- Rename the
menu_hash_to_str_us()
function tomsg_hash_to_str_xx()
and, inside that same function:- Replace the call to
menu_hash_to_str_us_label_enum()
with a call tomenu_hash_to_str_xx_label_enum()
- Replace the
#include "msg_hash_us.h"
line with #include "msg_hash_xx.h"
- Replace the call to
- Open
intl/msg_hash_us.h
- Add a
MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_XXXXX, "Xxxxx")
block with the name of the new language written in English - Copy
intl/msg_hash_us.h
tointl/msg_hash_xx.h
- Decide if
intl/msg_hash_xx.h
should use UTF-8 + BOM encoding. See the section below - Open
intl/msg_hash_xx.h
- Make sure to modify the
MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_XXXXX, "Xxxxx")
block to show the name of the new language written in the target language - Open
menu/menu_setting.c
- Add a
modes[RETRO_LANGUAGE_XXXXX] = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_LANG_XXXXX);
assignment to thesetting_get_string_representation_uint_user_language()
function - Open
griffin/griffin.c
- Add a
#include "../intl/msg_hash_xx.c"
line below the existing, similar
ones for other languages.
Encoding of translation files¶
- Translation files (
intl/msg_hash_xx.{c,h}
) in general must be UTF-8 encoded -
For some languages, these files need to have a "UTF-8 Unicode (with BOM)"
encoding, this is, UTF-8 and a
BOM. AFAIK this is so
because a requirement of the MSVC compilers (Windows platform). Examples of
this as of now are:msg_hash_ar.{c,h}
msg_hash_chs.{c,h}
msg_hash_cht.{c,h}
msg_hash_ja.{c,h}
msg_hash_ko.{c,h}
msg_hash_pl.{c,h}
msg_hash_ru.{c,h}
msg_hash_vn.h
-
Be careful when creating and editing your new translation files as some text
editors do strip the BOM without warning.
Translation¶
If you speak the target language xx then you could start translating literals in
intl/msg_hash_xx.c
intl/msg_hash_xx.h
by replacing the English original ones with its translations.