How it works on my project:
At first, we have a table with all needed languages. First column of the table is id (key) of our phrase. Then a comment column, and next rows are translations.
It looks like:
Second thing. As you can see on screenshot above we have an option in menu Export JSON.
This is small script for google docs which get all data from the cells and put it into JSON files on google disk (to folder of course)…
Third thing is size. The same field on different language can has the different size. We solve it by adding a note to the cell (it is scale x and y of text node):
Of course, script parse this data and put into special files scale_%lang.json
Then I use a modified i18n.lua library with lua module for Defold specific things.
Unfortunately for now we have no possability to add custom field to a text node. My workaround is: use a text property like a field for the id (key):
In code it looks like:
local lang = require "modules.localize.lang"
...
lang.by_node_name("text_node_name_1", 15) -- it is phrase with nuber like "15 things"
lang.by_node_names({"text_node_name_2", "text_node_name_3", "text_node_name_4"})
What I plan to do in this system for my project:
- possibility to use custom key (not from the text property of the node);
- change node font for different languages.
Why am I telling this?
To share this lib and pipeline require some extra work like clean-up the code - prepare it for public, make an instruction and so on.
Maybe my localization system is highly spesilized for my project and nobody need it… Then I have no sense to spend my time for this extra work.
Just give me know if you interested (you can Like this post for example) and I would happy to hear you suggestions in comments.
If I’ll see that it is interesting for Defold users I’ll share this library, example of google doc with export script and will make an instruction (of course when library will be fully ready and tested)