ttag-cli icon indicating copy to clipboard operation
ttag-cli copied to clipboard

Document how `update --sortByMsgid` works

Open dimaqq opened this issue 4 years ago • 4 comments

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...

dimaqq avatar Jul 17 '20 03:07 dimaqq

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 🤔

dimaqq avatar Jul 17 '20 03:07 dimaqq

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",

tlw44f avatar Jul 30 '20 18:07 tlw44f

I guess it's enough to document the behaviour.

dimaqq avatar Jul 31 '20 01:07 dimaqq

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.

mkosir avatar Aug 11 '20 11:08 mkosir