Gettext msgid's. Keys or Strings?

Hi all,

I’m heavily conflicted on gettext and how to best use the msgsid.
The official way of using gettext is by using the msgid as the text as needs to be displayed.

For example “Hi, %name}, good to see you again!”.

As far as I understand, the big reason for this is that when you change the text, you will automatically invalidate all the derived translations and thus it’s easy to pinpoint which ones need updating as well as the code becomes clear and you directly see what kind of text / purpose a gettext call has.

Now on the flip side you could also use msgid as keys.

For example “login-welcome-message-%{name}”

This way you say that its scoped for a login , the purpose is a welcome message and the keys that are available are %{name}. This makes it a bit harder to parse mentally but now the origin language can change without invalidating other translations. Which of course is both good and bad.

Coming to mind might be conversion optimisations where a “product-view-add-line-item-button-text” might change from “Buy” to “Add to cart” because you have seen some suggestions people prefer this. Though in the already translated languages it still makes sense to use translated version of “Buy”. So In this case your key is more relaying intent and purpose then the actual text used.

Regarding translating from the origin language to others, this would not really make a difference. When using the raw PO files you will have a bit of a hard time because the msgid are keys, and you will need to open the origin language one to see the original translation. Though most (online) translation tools use the origin language PO to extract the key and the base translation, so when translating in an other language, you will see the key, and the original translation, making it quite easy.

I am wondering if anyone could provide some input on their experiences with using either form and what the pro’s and con’s are based on the form they prefer.

Thanks for your time,
Gerard