Skip to content

How translations work

Ramiro Morales edited this page Mar 3, 2018 · 4 revisions
  • The msg_hash_to_str() function is used all over the RA code base
  • It accepts one argument, it gets passed an identifier e.g. msg_hash_to_str(MSG_AUTOSAVE_FAILED) (taken from here)
  • These identifiers are defined by enums in msg_hash.h
  • These identifiers are associated to the actual English literals in the intl/msg_hash_us.h and intl/msg_hash_lbl.h files
  • For this, a MSG_HASH() macro is used. It accepts two arguments: The identifier and the actual English string.
  • Example (from here):
    MSG_HASH(MSG_AUTOSAVE_FAILED,
          "Could not initialize autosave.")
  • Each translation to a language xxhas a intl/msg_hash_xx.h file with a similar structure. Example: German one is intl/msg_hash_de.h
  • Some language names do take in account the a country variation .e.g. msg_hash_pt_pt.h and msg_hash_pt_br.h

Encoding of translation files

  • Translations files (intl/msg_hash_xx.{c,h}) in general must be UTF-8 encoded
  • For some languages, the corresponding translation files need to have a "UTF-8 Unicode (with BOM)" encoding, this is, UTF and a BOM. AFAIK this is so because a requirement of the MSVC compiler (Windows platform)

Semantics of missing translations

When a intl/msg_hash_xx.h file doesn't have a MSH_HASH(ID, "Translation") entry for a given ID identifier, then it could means one of two things:

  • Translators haven't (yet) translated the English literal corresponding to ID
  • The actual translation to the target language is exactly equal to the English one. This is rare but it could happen. A trivial example: The word "Esperanto" means the same thing in English and Spanish (and Portuguese, ...)

Currently, there is no way to distinguish between both cases. This is a minor detail but makes impossible for developers and translators to track translation coverage statistics ("What percentage of the total RA UI literals have been already translated to language X?", "How many literals do I need to translate so the next RA release is fully translated to my language?")

The final result at runtime in both cases is that the original English literal is used in the RetroArch UI.

TO DO

  • Investigate and document msg_hash_xx.c files

Clone this wiki locally