diff --git a/Code.gs b/Code.gs index 247a4f2..78fe847 100644 --- a/Code.gs +++ b/Code.gs @@ -15,7 +15,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI The number of languages you support. Please check the README.md for more information on column positions. */ -var NUMBER_OF_LANGUAGES = 1; +var NUMBER_OF_LANGUAGES = 2; /* The script expects two columns for iOS and Android identifiers, respectively, @@ -40,6 +40,7 @@ var IOS_INCLUDES_LOCALIZABLE_ENUM = true; var LANGUAGE_IOS = 'iOS'; var LANGUAGE_ANDROID = 'Android'; +var LANGUAGE_WEB = 'Web'; var DEFAULT_LANGUAGE = LANGUAGE_IOS; @@ -50,6 +51,7 @@ function onOpen() { ui.createMenu('Custom Export') .addItem('iOS', 'exportForIos') .addItem('Android', 'exportForAndroid') + .addItem('Web (Json)', 'exportForWeb') .addToUi(); } @@ -71,6 +73,15 @@ function exportForAndroid() { exportSheet(e); } +function exportForWeb() { + var e = { + parameter: { + language: LANGUAGE_WEB + } + }; + exportSheet(e); +} + /* Fetches the active sheet, gets all of the data and displays the result strings. @@ -159,6 +170,9 @@ function makeString(object, textIndex, options) { case LANGUAGE_IOS: return makeIosString(object, textIndex, options); break; + case LANGUAGE_WEB: + return makeJsonString(object, textIndex, options); + break; default: break; } @@ -269,6 +283,33 @@ function makeIosString(object, textIndex, options) { return exportString; } +/* + Creates the Localizable.json file. +*/ +function makeJsonString(object, textIndex, options) { + + var exportString = ""; var prevIdentifier = ""; + exportString += "{\n"; + + for(var i=0; i