Why do people use plain english as translation pla

2019-01-23 01:04发布

This may be a stupid question, but here goes.

I've seen several projects using some translation library (e.g. gettext) working with plain english placeholders. So for example:

_("Please enter your name");

instead of abstract placeholders (which has always been my instinctive preference)

_("error_please_enter_name");

I have seen various recommendations on SO to work with the former method, but I don't understand why. What I don't get is what do you do if you need to change the english wording? Because if the actual text is used as the key for all existing translations, you would have to edit all the translations, too, and change each key. Or don't you?

Isn't that awfully cumbersome? Why is this the industry standard?

It's definitely not proper normalization to do it this way. Are there massive advantages to this method that I'm not seeing?

8条回答
别忘想泡老子
2楼-- · 2019-01-23 01:40

Well it probably is just that it's easier to read, and so easier to translate. I'm of the opinion that your way is best for scalability, but it does just require that extra bit of effort, which some developers might not consider worth it... and for some projects, it probably isn't.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-01-23 01:44

We've been using abstract placeholders for a while and it was pretty annoying having to write everything twice when creating a new function. When English is the placeholder, you just write the code in English, you have meaningful output from the start and don't have to think about naming placeholders.

So my reason would be less work for the developers.

查看更多
等我变得足够好
4楼-- · 2019-01-23 01:48
  1. The main language is already existent: you don't need to translate it.
  2. Translators have better context with a real sentence than vague placeholders.
  3. The placeholders are just the keys, it's still possible to change the original language by creating a translation for it. Because when the translation doesn't exists, it uses the placeholder as the translated text.
查看更多
We Are One
5楼-- · 2019-01-23 01:53

Interesting question. I assume the main reason is that you don't have to care about translation or localization files during development as the main language is in the code itself.

查看更多
啃猪蹄的小仙女
6楼-- · 2019-01-23 01:54

Yes, you have to alter the existing translation files, and that is a good thing.

If you change the English wording, the translations probably need to change, too. Even if they don't, you need someone who speaks the other language to check.

You prep a new version, and part of the QA process is checking the translations. If the English wording changed and nobody checked the translation, it'll stick out like a sore thumb and it'll get fixed.

查看更多
老娘就宠你
7楼-- · 2019-01-23 01:56

I like your second approach. When translating texts you always have the problem of homonyms. Like 'open' can mean a state of a window but also the verb to perform the action. In other languages these homonyms may not exist. That's why you should be able to add meaning to your placeholders. Best approach is to put this meaning in your text library. If this is not possible on the platform the framework you use, it might be a good idea to define a 'development language'. This language will add meaning to the text entries like: 'action_open' and 'state_open'. you will off course have to put extra effort i translating this language to plain english (or the language you develop for). I have put this philosophy in some large projects and in the long run this saves some time (and headaches).

The best way in my opinion is keeping meaning separate so if you develop your own translation library or the one you use supports it you can do something like this:

_(i18n("Please enter your name", "error_please_enter_name"));

Where:

i18n(text, meaning)
查看更多
登录 后发表回答