You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've implemented the above in our extraction.js file.
Path sorting as described above is implemented in the path-sort package, just used that.
constpofile=require("pofile");// From https://github.com/hughsk/path-sortconstpathsort=require("path-sort");constpathsortStandalone=require("path-sort").standalone();functiongetPotString(headers={}){constpo=newpofile();po.items=extractor.getPofileItems().sort((a,b)=>{returnpathsortStandalone(pathsort(a.references)[0],pathsort(b.references)[0]);});po.headers=Object.assign({'Content-Type': 'text/plain; charset=UTF-8'},headers);returnpo.toString();}fs.writeFileSync('./messages_js.pot',getPotString());
The generated POT file's messages are sorted alphabetically (i.e.
msgid "a"
is abovemsgid "b"
)In other implementations such as Python's Babel (http://babel.pocoo.org) messages are sorted by source file path. For example
Note that files in 'higher' directories are kept at the top and subdirectories come afterwards.
When messages are present in multiple files babel seems to select the directory with the least subdirectories as the sort key.
This makes translators lives easier in tools that rely on the order of messages in the PO files as similar messages are grouped together.
Can we have an option to set the sort order of the generated POT file?
The text was updated successfully, but these errors were encountered: