Hey Jon,
I’ve done it via the database at the moment. I have a massive .sql file with all the language text in, and will pass it on to others to edit. The format is easier for a non techie to edit than JSON I think.
I may create a front end for language translators, which is much more easily done if the text is in a database than a JSON file.
The other advantage is if I have 1000 text segments and someone only translates 900 into Spanish, I have a little stored procedure that will display the other 100 in English, so no part of my app is without text… or if I add 3 new text segments then they will be there in English until my Spanish translator gets to do their work on those 3.
Oh, and you may want to change the title of this post to something that includes the words “Language Translation” as maybe people don’t know what I18n is!
Best wishes,
Antony.
SQL FILE EXAMPLES:
-- Contacts
INSERT INTO apptext (lang_code, index_, app_text) VALUES ("en-GB", 100, "Contacts");
INSERT INTO apptext (lang_code, index_, app_text) VALUES ("es-ES", 100, "contactos");
INSERT INTO apptext (lang_code, index_, app_text) VALUES ("de-DE", 100, "Kontakte");
INSERT INTO apptext (lang_code, index_, app_text) VALUES ("en-GB", 101, "Work with all your business contacts");
...
-- email_cc
INSERT INTO apptext (lang_code, index_, field_name, app_text) VALUES ("en-GB", 8550, "email_cc", "Email address which emails can be copied to"); -- Field Title
INSERT INTO apptext (lang_code, index_, field_name, app_text) VALUES ("en-GB", 8551, "email_cc", "Email address which emails can be copied to"); -- Field Description
-- INSERT INTO apptext (lang_code, index_, field_name, app_text) VALUES ("en-GB", 8552, "email_cc", "Email address..."); -- Input Placeholder
INSERT INTO apptext (lang_code, index_, field_name, app_text) VALUES ("en-GB", 8559, "email_cc", "If an email address is specified here, then emails sent from the system will be copied to this address.
This can be useful if you wish to be sure messages have been sent.<br>
If you use this option, you may want to specify an address that is different from your usual address, such as emailcc@mydomain.com.
You can the set up your email system such as gmail to automatically bypass your inbox and route these emails to a particular folder.
For example, this is done in gmail via the Settings -> Folders option. It may also require you to ensure that an address such as emailcc at your domain will be forwarded to your email system."); -- Help Text
USE IN THE APP:
<dmx-value id="apptext" dmx-bind:value="get_apptext.data.get_apptext.toKeyedObject(`index_`, `app_text`)"></dmx-value>
...
<a ...>{{apptext.value.100}}</a>