Closed ysc3839 closed 3 years ago
I discussed about this PR on Discord with BiliGoldenWater who had some concerns about using automatic extraction.
It's friendlier for translators when they see resinTitle
instead of a hash like fxk59ds
. The descriptive ID gives an idea of where the message is being used in the UI ("resin" and "title") which can be helpful.
If a message in the en-US
localization changes, the message ID changes together which renders the translation of this message in all other localizations unusable and fall back to en-US
until updated by the translators again.
Having multiple files for a single localization (like en-US.json
and static.json
in this PR) makes it incompatible with online translation platforms.
This PR uses FormatJS extract
which actually does support explicit IDs. So in theory we can use explicit IDs as well as automatic extraction. But the point of automatic extraction is to avoid manually specifying IDs. So the benefit of a hybrid approach is questionable.
I'm not sure what the best approach is, and I don't know how other large projects handle localization. If you can input your opinion, that would be great!
The main problem of using ID is you have to manually manage the ID -> text
relations, which is easy to make errors and cost times.
There's many translate system. But macOS Cocoa, GNU gettext and Qt are using messages instead of ID. I don't know why they choose this, but I think they have their consideration.
Added extract script to generate po file.
Added generate script to generate json file from po file.
I think this PR is done.
When trnslating, use yarn extract
to extract translatable strings to template file en-US.pot
.
Then you can use tools like Poedit to translate.
After translate you get lang-code.po
(For example: zh-CN.po
), use yarn genlangs
to generate lang-code.json
.
Also names of characters, artifacts... should be added to a file, in order to allow generate script add them to the template file.
Fixed merge conflicts.
@phosphene47 Yes. In such case you have to specific an ID manually.
There is still some entries with id. I put them in
langs/static.json
. I think we need a script to manage the translation files.