ttag-cli
ttag-cli copied to clipboard
Document how `update --sortByMsgid` works
I'd love to see --sortByMsgid
documented better: that turning this option on after .po
files are already created will keep the original sort order of the old entries and sort the new entries according to message id.
Old
yarn tells me it ran path-to/node_modules/.bin/ttag update --extract-location=never --sortByMsgid int/ja-JP.po src
My .po file looks like this:
msgid "Loading..."
msgstr "ローディング..."
msgid "Batch Operations"
msgstr "バッチ操作"
msgid "Users"
msgstr "ユーザー一覧"
It doesn't appear sorted to me...
I think I know what's going on... maybe...
If a .po
files was originally created without sort; then sort was turned on and only a few translatable strings were changed/added/removed then only these "new" translatable strings are sorted alphabetically, while the rest of .po
files remains as is.
Maybe that's OK 🤔
I set up my local to have these scripts that will copy the existing po file, generate a new one, and then merge them back in together. Its not perfect but it does keep it organized.
"ttag:regenerate": "mv src/i18n/fr.po src/i18n/fr.old.po && npm run ttag:newPo && npm run ttag:update && mv src/i18n/fr.po src/i18n/fr.new.po && npm run ttag:merge && npm run ttag:update && rm src/i18n/fr.old.po && rm src/i18n/fr.new.po",
"ttag:newPo": "ttag init fr src/i18n/fr.po",
"ttag:merge": "ttag merge src/i18n/fr.new.po src/i18n/fr.old.po > src/i18n/fr.po",
"ttag:update": "ttag update src/i18n/fr.po src/ --numberedExpressions=true --sortByMsgid=true --extractLocation=file",
I guess it's enough to document the behaviour.
Came across the same issue as @dimaqq , I think --sortByMsgid
should sort also existing translations and newly inserted ones. Noticed that insertion of new translations works for extraction to .pot
files.