I have a .po file which follows the following format (keeping it slim – notice there is only a msgid and mstr as part of each set of strings):
msgid "hello everyone"
msgstr "bonjour toute la monde"
The msgid is the original text in english, and the msgstr is the translated text in french.
We are currently trying to use the library i18next-gettext-converter, but not sure how to do such a task with the library (if even possible), or if there’s a different javascript library that could meet our needs.
We would want our one large .po file to be able to generate 1 english translation and 1 french translation file so the react-i18next library can be used.
I’ve tried using the cli options with the -l and -s flags, and played around with the -K option flags, but nothing seems to even come close.
2
Answers
I think you should read the .po file and write a new file as you want, without any library, here is a snippet for you to start:
I’m not sure you fully described the problem, because
i18next-gettext-converter
seems to do exactly what you need.You can use it in command line by installing it globally:
So assuming you have
test.po
file with content:You can execute command:
And it will create
test.fr.json
for you:Is that what you want to achieve?
Otherwise, please, provide a sample of source and desired result files.