grow / grow

A declarative website generator designed for high-quality websites, with a focus on easy maintenance and localization.
https://grow.dev
MIT License
399 stars 51 forks source link

Translator comments not extracted for duplicate instances of tagged strings #284

Open WillsB3 opened 8 years ago

WillsB3 commented 8 years ago

If I have a translation tagged string like this in my doc:

thing_a@#: Here is a handy description of what the context of "Hello" is to assist translators.
thing_a@: Hello

and I have the exact same string in another doc, but have not provided a translator comment, like so:

thing_b@: Hello

The translator comment provided in thing_a@# doesn't get extracted to the .po file with the actual string for thing_a/thing_b.

Now, in my use case we've not had an instance where the same word has been used in multiple contexts, but I see that as potentially being a problem - If I provide a different translator comment for each occurrence of the word "Hello" should both comments be extracted into the .po...?

Should these be treated as two separate strings in the .po?...

stucox commented 8 years ago

Maybe they should be written to the PO as msgctxt rather than comments? The PO spec allows duplicate msgids, as long as they have different msgctxts.

jeremydw commented 8 years ago

I did some cursory digging but haven't found any good examples of msgctxt support in Jinja2 templates. We can alter the default i18n extension to add support for this. Have you been able to find any examples of folks that have implemented msgctxt support with Jinja2's i18n extension?

stucox commented 8 years ago

A quick Google threw this up: https://github.com/clouserw/tower — might be worth a look?

Otherwise, Django supports msgctxts, which could be used for inspiration.

Zoramite commented 7 years ago

Looking into this some more, there are two different routes that we could take to incorporate the msgctxt.

My preference would be to try and get the babel support functions working instead of trying to rely on django.