Replacements for gettext

后端 未结 5 1756
野趣味
野趣味 2021-01-13 07:56

We use gettext for translations in our product, but have had a lot of problems with it:

  • Can\'t use a language unless the system supports it.

On

5条回答
  •  长情又很酷
    2021-01-13 08:46

    We are using ICU resource bundles and are pretty satisfied with it. The ICU interface is not "modern", but it is powerful, the underlying principles are sound, and resources packaging (with the genrb tool) is pretty flexible. Its message formatting capabilities are also good.

    About your specific comments:

    Can't use a language unless the system supports it.

    I don't understand this one. This may be due to the fact that the only "experience" I have with gettext is having read its documentation.

    Uses environment to work out language

    The ICU interface takes a Locale as input, so you have complete control. It also has a concept of "default locale" if it is more convenient to you.

    Can't set a default language

    ICU has an elaborate fallback mechanism, involving a "default" bundle

    Encoding the are returned vary between UTF-8 and current local encoding.

    String ResourceBundles (other data types are also possible) are always represented as UnicodeString, which is internally encoded in UTF-16. UTF-32 with UnicodeString is pretty easy, as its interface exposes several methods allowing to manipulate it at the codepoint level. For other encodings, code conversion is possible.

提交回复
热议问题