Gettext: Is it a good idea for the message ID to be the english text?

后端 未结 11 1348
春和景丽
春和景丽 2020-12-07 16:45

We\'re getting ready to translate our PHP website into various languages, and the gettext support in PHP looks like the way to go.

All the tutorials I see recommend

相关标签:
11条回答
  • 2020-12-07 17:06

    We use Dutch. The strings should be written in the native language of the writer; this makes communication with translators less prone to errors, since the writer(s) can communicatie in their native language with them.

    0 讨论(0)
  • 2020-12-07 17:13

    Wow, I'm surprised that no one is advocating using the English as a key. I used this style in a couple of software projects, and IMHO it worked out pretty well. The code readability is great, and if you change an English string it becomes obvious that the message needs to be considered for re-translation (which is a good thing).

    In the case that you're only correcting spelling or making some other change that definitely doesn't require translation, it's a simple matter to update the IDs for that string in the resource files.

    That said, I'm currently evaluating whether or not to carry this way of doing I18N forward to a new project, so it's good to hear some thoughts on why it might not be a good idea.

    0 讨论(0)
  • 2020-12-07 17:14

    I'd go so far as to say that you never (for most values of never) want to use free text as keys to anything. Imagine if SO used the query title as key to this page for instance. If someone links to it, and then the title is edited, the link is no longer valid.

    Your problem is similar, except you would also be responsible for updating all links...

    Like Douglas Leeder mentions, what you probably want to do is use English as the default (backup) language, although an interface that uses English and another language intermixed is highly confusing (but mildly amusing, too).

    0 讨论(0)
  • 2020-12-07 17:15

    Haven't you already answered your own question? :)

    Clearly, if you intend to support i18n of your application, you should treat all the language implementations the same. If someone decides a string needs to change, you make a similar change in all the language files. The metadata with the checkin should group all the language files together in the same change. If your "default" language is handled differently, that makes it more difficult to maintain.

    0 讨论(0)
  • 2020-12-07 17:19

    I strongly disagree with Richard Harrisons answer about which he states it is "the only way". Dear asker, do not trust an answer that states it is the only way, because the "only way" doesn't exist.

    Here is another way which IMHO has a few advantages over Richards approach:

    • Start with using the proto-version of the English string as Original.
    • Don't display these proto-strings but create a translation file for English nontheless
    • Copy the proto-strings to the translation for the beginning

    Advantages:

    • readable code
    • text in your code is very close if not identical to what your view displays
    • if you want to change the English text, you don't change the proto-string but the translation
    • if you want to translate the same thing twice, just write a slightly different proto-string or just add 'version for this and that' and you still have a perfectly readable code
    0 讨论(0)
  • 2020-12-07 17:19

    There is a lot to consider and answer is not so easy.

    Using plain English

    Pros

    • Easy to write and READ code
    • In most cases, it works even without running translation functions in code

    Cons

    • Involved programmers must be also good copywriters :)
    • You need to write correct precise texts fully in English, even in the case that first language you need to run is something else (ie we're starting lof of projects in Czech language and we're localizing them to EN later).
    • In a lot of cases, you need to use contexts. If you fail to do it from begginig, it's a lot of work to add them later. To explain: In English, one word can have many different meands - and you need to use contexts to differentiate them - and it's not always so easy (order = sort order, or it can be purchase order).
    • It can be very hard to correct English later in the process. Corrections of the source strings will very often lead to loss of already translated phrases. It's very frustrating to loose translation to 3 different languages just because you corrected English.

    Using keys

    Pros

    • You can use localization platform functions even for the English language. I.e. we're using the lovely Crowdin platform. There is a lot of handy tools - or rather a complete workflow - for translation management: voting for different translations, translation history, glossaries (which helps to keep translation/language coherent), proofing, approval, etc. Using keys make this process much more smooth.

    • It's much easier to send Engish texts for proofreading etc. Usually, it's not a good idea to let copywriters to modify your code directly :)

    Cons

    • More complicated project setup.
    • Harder to use %d, %s etc.
    0 讨论(0)
提交回复
热议问题