Adding a translation to a new language

Files you need to change

Instructions

  1. Open libretro-common/include/libretro.h
  2. Add a RETRO_LANGUAGE_XXXXX item to the retro_language enum just above RETRO_LANGUAGE_LAST, using the next available integer value
  3. Open msg_hash.h
  4. Add a MENU_ENUM_LABEL_VALUE_LANG_XXXXX item to the msg_hash_enums enum
  5. Add declaration of a const char *msg_hash_to_str_xx(enum msg_hash_enums msg) function
  6. Add declaration of a int menu_hash_get_help_xx_enum(enum msg_hash_enums msg, char *s, size_t len) function
  7. Open msg_hash.c
  8. Add a
    c case RETRO_LANGUAGE_XXXXX: ret = menu_hash_get_help_xx_enum(msg, s, len); break;
    block inside the menu_hash_get_help_enum() function
  9. Add a
    c case RETRO_LANGUAGE_XXXXX: ret = msg_hash_to_str_xx(msg); break;
    block inside the msg_hash_to_str() function
  10. Open Makefile.common
  11. Add intl/msg_hash_xx.o to OBJS
  12. Copy intl/msg_hash_us.c to intl/msg_hash_xx.c
  13. Decide if intl/msg_hash_xx.c should use UTF-8 + BOM encoding. See the section below
  14. Open intl/msg_hash_xx.c
  15. Rename the menu_hash_get_help_us_enum() function to menu_hash_get_help_xx_enum()
  16. Rename the menu_hash_to_str_us_label_enum() function to menu_hash_to_str_xx_label_enum()
  17. Rename the menu_hash_to_str_us() function to msg_hash_to_str_xx() and, inside that same function:
    • Replace the call to menu_hash_to_str_us_label_enum() with a call to menu_hash_to_str_xx_label_enum()
    • Replace the #include "msg_hash_us.h" line with #include "msg_hash_xx.h"
  18. Open intl/msg_hash_us.h
  19. Add a
    c MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_XXXXX, "Xxxxx")
    block with the name of the new language written in English
  20. Copy intl/msg_hash_us.h to intl/msg_hash_xx.h
  21. Decide if intl/msg_hash_xx.h should use UTF-8 + BOM encoding. See the section below
  22. Open intl/msg_hash_xx.h
  23. Make sure to modify the
    c MSG_HASH(MENU_ENUM_LABEL_VALUE_LANG_XXXXX, "Xxxxx")
    block to show the name of the new language written in the target language
  24. Open menu/menu_setting.c
  25. Add a
    c modes[RETRO_LANGUAGE_XXXXX] = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_LANG_XXXXX);
    assignment to the setting_get_string_representation_uint_user_language() function
  26. Open griffin/griffin.c
  27. Add a #include "../intl/msg_hash_xx.c" line below the existing, similar
    ones for other languages.

Encoding of translation files

Translation

If you speak the target language xx then you could start translating literals in

by replacing the English original ones with its translations.

Example: Addition of Arabic language:

See also