For a website with a large amount of fixed strings (labels, announcements and etc), I’m going to add internationalization to the project and I want to know your experiences about using keywords vs real phrases in the original codes? Which one is better to use?
Check this example – in django:
Real phrase:
<p>
{% trans "Welcome to my website" %}
</p>
Keyword:
<p>
{% trans "WELCOME_MESSAGE" %}
</p>
Of course using real phrases is easier, but I have some bad experiences. Consider a general word, {% trans "contacts" %} used as title of a page and somewhere else used in a phrase like {{selected_contacts_count}}{% trans "contacts" %}, translation of contacts as title of a page can be different with translation of contacts as a word in a phrase, so this is a conflict.
Keywords.
Somewhere , sometime, someplace, you’ll need to have a translation table. It might be flat file, it might be a db store, but it’ll probably look like this:
it’ll be much easier to build and maintain a keyword based system :
If you’re interpolating data into these translation, the one issue that you’ll likely encounter is having to deal with pluralizations:
So keep that in mind as you move forward.