WordPress.org

Ready to get started?Download WordPress

Forums

Internationalization / Localization and gettext (2 posts)

  1. fireproofsocks
    Member
    Posted 3 years ago #

    This isn't a question about WordPress, but about one of its components: gettext. That's the localization framework that drives all of the translations printed by the __() and _e() functions.

    My question is about how gettext expects its input -- if I'm developing in German for example, can I wrap my German messages using this function? Or do the "original" messages always need to be in English?

    Some translation engines work based off of a number, e.g. error #123 gets looked up in the English, German, or Japanese file and prints the translated message corresponding to "123". But from what I've read about gettext it seems that it uses English as the common denominator. Is that true? Does anyone know?

  2. fireproofsocks
    Member
    Posted 3 years ago #

    For the record, gettext basically uses "message ids", so if you happen to be writing your messages in German, then that's treated as a unique message identifier (in the same way that an error code or message #123 is treated as a message identifier).

    What that means is that the messages passed to the __() functions are language agnostic. All of those identifiers will appear in your language .pot file, and they are language agnostic UNTIL you actually translate them into a .po file. Now, in practice, those message identifiers are in your native language, so the act of "translating" your identifiers from your .pot file to your locale's .po file is nothing more than copying and pasting.

    This means you can rely on gettext and use any language you want to identify your messages.

Topic Closed

This topic has been closed to new replies.

About this Topic