adams85 / po

A library for reading and writing Gettext PO files.
MIT License
61 stars 16 forks source link

Enforce GNU gettext header order by default #22

Closed samhocevar closed 1 year ago

samhocevar commented 1 year ago

Note: the actual changes are in POGenerator.cs, the rest is mostly fixing the unit tests.

By default, i.e. when not asked to preserve header order, the library sorts them alphabetically. This is contrary to GNU gettext behaviour (see the construct_header() function here) as well as the Python polib library (see the ordered_metadata() function here).

This PR ensures that when not explicitly requested to preserve header order, the library serialises them in an order compatible with GNU gettext and polib. All unit tests were fixed accordingly.

samhocevar commented 1 year ago

By the way, the reason this is important is because it creates all sorts of source control conflicts when different tools are used to edit PO data.

adams85 commented 1 year ago

This change makes perfect sense. Thanks for the contribution!

adams85 commented 1 year ago

FYI, just released this in v1.10.0.