I've a .po file I need to copy msgid value into msgstr value if msgstr is empty.
For example
msgid "Hello"
msgstr ""
msgid "Dog"
msgstr "Cane"
Should become
msgid "Hello"
msgstr "Hello"
msgid "Dog"
msgstr "Cane"
Currently, for testing purpose, I'm working with another file, but final script will works inline.
#!/bin/bash
rm it2.po
sed $'s/^msgid.*/&\\\n---&/' it.po > it2.po
sed -i '/^msgstr/d' it2.po
sed -i 's/^---msgid/msgstr/' it2.po
This script has 2 problems (at least):
- copies msgid into msgstr also when msgstr is not empty;
- I'm pretty sure that exist a single line or a more elegant solution.
Any help would be appreciated. Thanks in advance.