On Thursday, 23 May 2013 at 08:31:46 UTC, Jacob Carlborg wrote:
On 2013-05-23 10:29, Jacob Carlborg wrote:
Say I have:
gettext("%s: unknown variable at line %s")
Then I want to change the text to:
gettext("%s: not yet known variable at line %s")
I have to find all places where this text is used in the code.
Then I
also need to updated the translations. If I used a key instead
I only
need to update all the translations. I don't need to change my
code.
Also, with the key approach I can just send a separate file to
someone else to do the translation, even the English
translation. Sure I probably could have a separate file for the
English translation as well but that would be duplicating the
string.
Given a change that is purely aesthetic like that you could just
change the english translation instead... Also "find and replace"
takes a few seconds...
If you are suggesting to use a named constant as a key, this also
suffers from the exact problem you are pointing out that if you
need to change the name slightly you need to do it in all places
that constant is used in the code.
It also suffers from the fact that unless you use unreasonably
long names for the constant you can't easily tell what it
contains.
Plus assuming these constants are internally numbered and that is
the key used, you get the problem of translations matched to the
wrong key and nobody realising because the key does not relate in
any way to the meaning. With a text key the only time you reuse a
key is if it has the same meaning.