elixir-gettext / gettext

Internationalization and localization support for Elixir.
https://hexdocs.pm/gettext
461 stars 87 forks source link

Dump flags after references in PO files #310

Closed wpiekutowski closed 2 years ago

wpiekutowski commented 2 years ago

Summary

This PR changes the order in which flags and references are dumped into PO files, so that flags are placed after references. This behavior seems to be common among a small sample of non-Elixir PO files I saw.

Background

In of the projects, I'm going to use transifex.com to enable easier management of translations. However, I've noticed that they output comments in PO files in a different order than Elixir's gettext. They first output file references and then flags, while Elixir's gettext does it the other way. This results in some unnecessary churn in git history, because these 2 lines are swapped back and forth. Folks at transifex.com insist that Elixir's gettext is outputing comments in the wrong order:

After investigation, our team concluded that the resulting order of the comments is not caused by a bug in our parser. Instead, our parser while following the PO file entry schematic structure, arranges the comments in the order specified in the GNU guidelines. You can find more information about this here.

Since these are the best practices for PO file handling our advice would be to follow them to avoid any future issues.

However, I wasn't able to find any explicit mention of the "standard" comment order in PO files, except for the example PO file in the linked gettext doc. My short GitHub research indicated that indeed PO files with flags (that I've found) had them placed after the references, so that gives some additional credibility to transifex claim.

whatyouhide commented 2 years ago

This will potentially generate large diffs for folks with lots of PO files. It's alright, just something that we might want to call out in the CHANGELOG. 🙃

Thanks @wpiekutowski! ❤️

wpiekutowski commented 2 years ago

Thanks for the quick review and merge!

I agree it's a good idea to explain these large diffs in the CHANGELOG, although I suppose they won't be significantly bigger than the ones resulting from 0.19.1 ex-autogen -> elixir-autogen rename.