Skip to content

Commit

Permalink
feat(translate): added the translationsSchema.json file into a bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanKrasinskyi committed Feb 19, 2020
1 parent e855cb8 commit ba04cd6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/theme-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ ThemeConfig.prototype.setThemePath = function (themePath) {
this.themePath = themePath;
this.configPath = Path.join(themePath, 'config.json');
this.schemaPath = Path.join(themePath, 'schema.json');
this.schemaTranslationsPath = Path.join(themePath, 'schemaTranslations.json');
this.variationIndex = 0;

return this;
Expand Down Expand Up @@ -370,6 +371,36 @@ function fetchThemeSettings(path, callback) {
});
};

/**
* Get Schema Translations
*
* @param {Function} callback
*/
ThemeConfig.prototype.getSchemaTranslations = function(callback) {
var schemaTranslationsContent;
var schemaTranslations;

try {
schemaTranslationsContent = Fs.readFileSync(this.schemaTranslationsPath, {encoding: 'utf-8'})
} catch (err) {
return callback(null, {});
}

if (schemaTranslationsContent) {
try {
schemaTranslations = jsonLint.parse(schemaTranslationsContent, this.schemaTranslationsPath);
} catch (err) {
return callback(err);
}
}

if (!_.isObject(schemaTranslations)) {
schemaTranslations = {};
}

return callback(null, schemaTranslations);
};

/**
* Return the raw config.json data
*
Expand Down

0 comments on commit ba04cd6

Please sign in to comment.