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)
Add it structurally in quest.json
Steps to add a new quest format
Find the law of the quest and requirement strings between each languages
Define the structure of requirement item in quest.json
Write the processing function in reqstr.coffee
Write format strings for each language in assets/i18n/xx_xx.json
Features
Automatically reads window.traslate which is the translations from plugin-translator.
Translates the name of every ship, items or other tokens. After all, they are just filling the blank!
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 functionreqstr()
fromreqstr.coffee
will give you the requirement text.Module
reqstr.coffee
is loaded with the configuredi18n
module as an argument so that it can know which set of formats to read from. Although the samereqstr()
function is used, text in each language can be produced by reading differentassets/i18n/xx_xx.json
.Note that in
index.cjsx
thei18n
module is wrapped and duck-typed, to acceptwindow.translate
as fallback, which is thei18n
module of optional plugin-translator.Steps to add a new quest (of existing format)
quest.json
Steps to add a new quest format
requirement
item inquest.json
reqstr.coffee
assets/i18n/xx_xx.json
Features
window.traslate
which is the translations from plugin-translator.Other improvements