poooi / plugin-quest

show quest info
MIT License
4 stars 7 forks source link

New i18n mechanism #17

Closed dkwingsmt closed 8 years ago

dkwingsmt commented 8 years ago

A new i18n mechanism is implemented in order to make quest requirement texts easier to maintain for multiple languages.

We observe that there are only a few "categories" of quests, despite they apply to different details, such as different ships, different maps, whether going to boss, whether requiring S-rank, etc. Therefore by defining those categories and implementing the text of each category in every languages, the text for each new quest can be derived by just filling the blank.

Implementation

The i18n format strings of each quest category are placed in assets/i18n/xx_xx.json according to the languages. Providing an object of the quest detail to function reqstr() from reqstr.coffee will give you the requirement text.

Module reqstr.coffee is loaded with the configured i18n module as an argument so that it can know which set of formats to read from. Although the same reqstr() function is used, text in each language can be produced by reading different assets/i18n/xx_xx.json.

Note that in index.cjsx the i18n module is wrapped and duck-typed, to accept window.translate as fallback, which is the i18n module of optional plugin-translator.

Steps to add a new quest (of existing format)

Ayaphis commented 8 years ago

holy...

dkwingsmt commented 8 years ago

啥⋯⋯