COCOS2DX 3.0 CocoStudio1.4.1
Do interface when using the Cocostudio generated Ui.json file, need to do language localization, forum friends gave the method:
The localization of the picture format, in English called Button_store_normal.en.png Chinese called button_store_normal.zh.png ...
According to this rule, load different pictures according to the language you need.
We're using a different approach:
Modify the JSON file, this is not the real modification of the JSON file, just after reading the JSON file into memory, not immediately handed over to the Guireader generation widget, but in accordance with the desired language, replace the corresponding resource path in the JSON file
The resource directory is as follows:
Resource/data/ui.json
Resource/data/pic //ui.json Use of the image directory without localization
Resource/data/local_en//Storage of the English version of the picture resources
Resource/data/local_zh//Storage of Chinese version of picture resources
......
The JSON file is as follows:
"Texturespng": ["Pic/ui/weaponscene/bg.png", "Pic/ui/weaponscene/weapon_sel_close.png", "pic/ui/weaponscene/we Apon_sel_close1.png "," Pic/ui/weaponscene/slider_bar.png "," Pic/ui/weaponscene/slider_btn.png "," Pic/ui/weaponsce Ne/weapon_sel_bg.png "," Pic/weapon_1.png "," Pic/ui/bullet_flag.png "," Pic/ui/weaponscene/money_buy_bullet.png ", "Pic/ui/weaponscene/money_buy_bullet1.png", "Local_en/weapon_select_scene/jiemian_upgrade_5.png", "local_en/ Weapon_select_scene/jiemian_upgrade_5_1.png "," Pic/ui/weaponscene/progress2.png "," pic/ui/weaponscene/ Progress1.png "," Pic/ui/weaponscene/progress.png "," Local_en/weapon_select_scene/jiemian_sttack_4.png "," local_en /weapon_select_scene/jiemian_xuanzhong_6_5.png "," Local_en/weapon_select_scene/jiemian_xuanzhong_6_6.png "," Local_en/weapon_select_scene/jiemian_xuanzhong_6_7.png "," Local_en/weapon_select_scene/jiemian_xuanzhong_6_8. PNG "," Local_en/weapon_select_scene/jiemian_go.png "," LoCal_en/weapon_select_scene/jiemian_go_1.png "," Local_en/weapon_select_scene/jiemian_shop.png "," Local_en/weapon_ Select_scene/jiemian_shop_1.png "...],
Pic/ui/*.png is not required for multi-lingual processing
Local_en/*.png is our default Design language directory
After reading the Ui.json file, we replace "local_en/" with the language we need, such as "local_zh/", and the rest is to determine the language of the problem.
If you have a better idea, share it with me.