turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

Categorised translations or adding multi-file support to PostBuild #339

Open ajbeaven opened 7 years ago

ajbeaven commented 7 years ago

It'd be great to be able to categorise a translation so a subset of translations could be handled separately. My site has an administration backend that needs to have different translations available to that of the public site.

Currently, PostBuild dumps all the translations in to a single file messages.pot/messages.po and only these files are used to display translations. It would be nice if multiple translation files could be generated and used based on a single in a nugget. Perhaps something like this:

[[[This translation is the default case]]]
[[[This translation is a special case\\\specialcase]]]
[[[This translation is another special case\\\specialcase]]]

The first nugget would be added to the default messages.pot and the others generate .pot/.po files based on the key specified in the nugget:

messages.pot
- This translation is the default case

specialcase.pot
- This translation is a special case
- This translation is another special case

Because all translations are currently dumped in a single file, translators are required to sift through all translations as many may not be relevant for them. Unless I add comments to each nugget, this is often an impossible task. It would be a better experience for the translators for me to send them a single .po file and they can just simply translate them all.

I understand that reading multiple .po files is already supported (i18n.LocaleOtherFiles) so perhaps this just needs to be an improvement to PostBuild that allows it to generate the separate PO databases. The changes added in #314 may be useful here and to many, may be a more elegant approach.

Sshnyari commented 7 years ago

Here is a start for doing this. I didn't submit a PR because it still has some issues :

categorized-po-files.zip