localize-joi
Translate your JSON using joi
Build Status - Master
Add localizable string objects in your joi schema:
- translate, is_machine_translated, is_dirty, value, and language are all required properties
- localizedString is a required tag in order for translation to occur
...name: Joiobjecttags'localizedString'...
translate
a boolean indicating whether the localizableString should be translated
is_machine_translated
a boolean indicated whether the localizableString should be translated by the translationProvider (i.e. Google)
is_dirty
a boolean flag indicating whether the text has been changed since last translation
value
string value to be translated
language
source language (i.e. 'en') of the text to translate
Provide configuration
(only Google Translate API is supported at this time)
var config = translationProvider: 'google' apiKey: 'yourGoogleApiKey';
Initialize instance
var Localize = ;var localize = config;
Run translation
localize;
Full example
var config = translationProvider: 'google' apiKey: 'yourGoogleApiKey'; var Localize = ;var localize = config;var joi = ; var joiSchema = Joiobject; var jsonObject = id: '97170e81-8b55-4cad-8748-5a94658b91d6' data: name: translate: false value: 'testing model name' is_dirty: false is_machine_translated: true language: 'en' nested: nested_name: translate: true value: 'testing model nested name' is_dirty: false is_machine_translated: true language: 'en' description: translate: true value: 'this is a description of the testing model' is_dirty: false is_machine_translated: true language: null is_active: true message: translate: true value: 'this is the message of the testing model' is_dirty: false is_machine_translated: false language: 'en' images: '1892d407-28db-4c91-ad5b-bd2c596a201d' 'edc9593f-6441-4e0d-94c3-c1b4ccd7d25d' 'cdcd0518-86ba-45e8-a7d2-675867cab29a' ordinal: 0 created_on: updated_on: ; localize;