MCprep
MCprep copied to clipboard
The Beginning of i18n Support
Currently MCprep only supports English as a language option, but Minecraft animation is a much much more diverse field. As such, we need add some system to MCprep to allow i18n support. i18n support was proposed back in #165, and now it's time we start thinking about it, especially as MCprep's new architecture now makes it easier to add. Our goal is the following:
"Let no Minecraft animator be confused by MCprep's UI simply because of the language they speak"
~~As such, this will be marked as high priority for MCprep 3.5.1, and the lack of basic i18n support should be considered a blocker for the MCprep 3.5.1 release.~~ EDIT: as per #481, I've pushed this to MCprep 3.6, so this is no longer a 3.5.1 blocker
Ideally we'd want to use the system proposed here, to make it as easy as possible for users to create translations.
To begin i18n support, we need the following:
- [x] Ability to load JSON files at startup
- [ ] Migrate MCprep's panels to use the setup as defined in this guide
- [ ] Create a system for users to add their own translations in a way that makes sure Google Translate and other AI translators aren't used (especially in non-European languages, AI translators tend to do a poor job at translating)
- [ ] Document the JSON format
Whoops, sorry for the blank issue, let me add some description
Added a basic mechanism of loading language files. This also adds the option of not just supporting full languages, but also dialects. https://github.com/TheDuckCow/MCprep/commit/bc852c4e8dd324ca1153dbbac2382cefb53cfb01
https://github.com/TheDuckCow/MCprep/blob/bc852c4e8dd324ca1153dbbac2382cefb53cfb01/MCprep_addon/conf.py#L68-L87
Alright I'm considering this format since it seems to be a little easier to understand, but it doesn't update everything on the fly (some things require a restart).
Cool, this format is easy to understand. Since I am working on i18n of BLUE PROTOCOL (community,not official). I have found some issue about the format to use.
First, it's strongly recommend to have the identitiy key for every field. Here is the thing, when we start translate, we will change every original text, so keep an identitiy key can help us know the association between original text and translated text.
Then. use json to exchange translation file with others. JSON is easy to work with many languages, some body may like to use i18n platform like Weblate, that is, json can easily convert to the format which platform needs.
First, it's strongly recommend to have the identitiy key for every field. Here is the thing, when we start translate, we will change every original text, so keep an identitiy key can help us know the association between original text and translated text.
So like "string X is represented as insert ID for x"? That would be easier to handle Blender side as one way (there's multiple ways) to translate in Blender is with the following:
langs = {
'test_text_in_bl_ui': {
'en_US': 'Test text in Blender UI',
'es': 'Prueba de texto en la interfaz de usuario de Blender',
'ja_JP': 'Blender ユーザーインターフェースでテキストをテストする'
}
}
Where each piece of text has an ID and different strings for each language.
Then. use json to exchange translation file with others. JSON is easy to work with many languages, some body may like to use i18n platform like Weblate, that is, json can easily convert to the format which platform needs.
Can you give an example of what you mean?
just like this. I export uasset to json and make some python scripts, then convert to GETTEXT and import in weblate.
it's also ok if somebody want to directly translate with Text Editor,
In that case, we could make the format of translation files be the following:
"language" : "<insert language>",
"translation" : {
"prep_materials_op" : "<insert translation>"
}
LGTM
Alright I've gone though a part of MCprep's UI (not all of it, just part of the world tools panel) and added support for translations. Just know at the moment, MCprep follows whatever language Blender is set to (and falls back to English if an option does not exist). These are the languages in Blender at the moment:
The language
key in JSON must follow whatever bpy.app.translations.locale
equals to. For English, that would be en_US
. I've pushed a JSON file for English as reference (on GitHub, it's MCprep_addon/MCprep_resources/Languages/en_US.json
)
nice, I will make a pr soon
Alright so a slight change to the JSON format: language
now defines the name of the language, and locale
defines the locale. Using English as an example:
This:
https://github.com/TheDuckCow/MCprep/blob/a3b0fa820e1b108331a8e543c9446483f0b9b9c1/MCprep_addon/MCprep_resources/Languages/en_US.json#L1-L2
becomes this: https://github.com/TheDuckCow/MCprep/blob/44fa48be164607efa711aefd43d9a5ddc205bf0a/MCprep_addon/MCprep_resources/Languages/en_US.json#L1-L3
The reason is because although MCprep currently follows Blender's locale, we also want to eventually allow MCprep to have its own locale settings (still following Blender by default, but with more options beyond what Blender supports), so we want to be able to list all of the languages MCprep supports.
Some languages I can't translate, I don't know how they are connected!
maybe they have't extract strings to json file.
Some languages I can't translate, I don't know how they are connected!
We can't translate "dynamic" menus like mob rigs, blocks, items, etc since their names are extracted from files that could change and not actually defined in Python
Alright, some new translatable strings have been added:
{
"item_from_texture" : "Generate items from textures",
"no_items_loaded" : "No items loaded",
"place_item" : "Place item",
"import_entities" : "Import pre-rigged entities",
"entity_blend" : "Entity file must be a .blend",
"entity_file_not_found" : "Entity file not found",
"reset_entity_path" : "Reset entity path",
"spawn_entity" : "Spawn Entity",
"select_exporter" : "Select exporter!"
}
Meanwhile meshswap_file_not_found
has been removed as it was a duplicate.
Sorry for the delay, I'm a bit preoccupied at the moment (frankly the rest of 2023 is a bit hectic for me). Hopefully I can get the rest of mcprep_ui
in the next couple of weeks, which I'd say would make about a quarter to half of MCprep itself translatable.
An update on this issue: we've moved from JSON to PO and gettext
, so now the entire N panel is (or at least should be) available for translation.
A guide for translation can be found here: https://github.com/Moo-Ack-Productions/MCprep/blob/i18n-support-attempt-3/docs/i18n/translating.md
try hosting on weblate? they may provide WebUI for po files and free tier for opensource projects.
We've discussed Weblate as an option at the recent dev meeting; currently experimenting with it but if we think it's good for our purposes, we'll roll it out after MCprep 3.6 launches.
The first level of i18n support in MCprep has been merged. There's still a lot of work to do before MCprep becomes 100% translatable, but I'll close this issue as completed now that we have the first step done.