diff --git a/gulpfile.js b/gulpfile.js index 2296ffaa8..01a2deb13 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -59,39 +59,39 @@ function treatMergedData(data) { var mergedOrdered = {}; for (var filepath in data) { + var pathSplit = filepath.split('/'); - if (filepath.indexOf('lang/') === 0 || filepath.indexOf('core/lang') === 0) { + pathSplit.pop(); - addProperties(merged, data[filepath], 'core.'); + switch (pathSplit[0]) { + case 'lang': + prefix = 'core'; + break; + case 'core': + if (pathSplit[1] == 'lang') { + // Not used right now. + prefix = 'core'; + } else { + prefix = 'core.' + pathSplit[1]; + } + break; + case 'addon': + // Remove final item 'lang'. + pathSplit.pop(); + // Remove first item 'addon'. + pathSplit.shift(); - } else if (filepath.indexOf('core/') === 0) { - - var componentName = filepath.replace('core/', ''); - componentName = componentName.substr(0, componentName.indexOf('/')); - addProperties(merged, data[filepath], 'core.'+componentName+'.'); - - } else if (filepath.indexOf('addons') === 0) { - - var split = filepath.split('/'), - pluginName = split[1], - index = 2; - - // Check if it's a subplugin. If so, we'll use plugin_subfolder_subfolder2_... - // E.g. 'mod_assign_feedback_comments'. - while (split[index] && split[index] != 'lang') { - pluginName = pluginName + '_' + split[index]; - index++; - } - addProperties(merged, data[filepath], 'mma.'+pluginName+'.'); - - } else if (filepath.indexOf('assets/countries') === 0) { - - addProperties(merged, data[filepath], 'core.country-'); - - } else if (filepath.indexOf('assets/mimetypes') === 0) { - - addProperties(merged, data[filepath], 'core.mimetype-'); + // For subplugins. We'll use plugin_subfolder_subfolder2_... + // E.g. 'mod_assign_feedback_comments'. + prefix = 'addon.' + pathSplit.join('_'); + break; + case 'assets': + prefix = 'assets.' + pathSplit[1]; + break; + } + if (prefix) { + addProperties(merged, data[filepath], prefix + '.'); } } @@ -181,7 +181,7 @@ var appLangFiles = ['ar.json', 'bg.json', 'ca.json', 'cs.json', 'da.json', 'de.j lang: [ './src/lang/', './src/core/**/lang/', - './src/addons/**/lang/', + './src/addon/**/lang/', './src/assets/countries/', './src/assets/mimetypes/' ], diff --git a/src/providers/utils/mimetype.ts b/src/providers/utils/mimetype.ts index 589c14b32..096365aaf 100644 --- a/src/providers/utils/mimetype.ts +++ b/src/providers/utils/mimetype.ts @@ -323,7 +323,7 @@ export class CoreMimetypeUtilsProvider { let filename = '', mimetype = '', extension = '', - langPrefix = 'core.mimetype-'; + langPrefix = 'assets.mimetypes.'; if (typeof obj == 'object' && typeof obj.file == 'function') { // It's a FileEntry. Don't use the file function because it's asynchronous and the type isn't reliable. @@ -422,7 +422,7 @@ export class CoreMimetypeUtilsProvider { * @return {string} Translated name. */ getTranslatedGroupName(name: string) : string { - let key = 'core.mimetype-group:' + name, + let key = 'assets.mimetypes.group:' + name, translated = this.translate.instant(key); return translated != key ? translated : name; } diff --git a/src/providers/utils/utils.ts b/src/providers/utils/utils.ts index d75334f2d..4160cbca8 100644 --- a/src/providers/utils/utils.ts +++ b/src/providers/utils/utils.ts @@ -552,7 +552,7 @@ export class CoreUtilsProvider { * @return {string} Country name. If the country is not found, return the country code. */ getCountryName(code: string) : string { - let countryKey = 'core.country-' + code, + let countryKey = 'assets.countries.' + code, countryName = this.translate.instant(countryKey); return countryName !== countryKey ? countryName : code; @@ -580,8 +580,8 @@ export class CoreUtilsProvider { let countries = {}; for (let name in table) { - if (name.indexOf('core.country-') === 0) { - let code = name.replace('core.country-', ''); + if (name.indexOf('assets.countries.') === 0) { + let code = name.replace('assets.countries.', ''); countries[code] = table[name]; } } diff --git a/tslint.json b/tslint.json index dd8e8d887..7cecb9d18 100644 --- a/tslint.json +++ b/tslint.json @@ -3,7 +3,15 @@ "no-duplicate-variable": true, "no-unused-variable": [ true - ] + ], + "max-line-length": { + "options": [132] + }, + }, + "jsRules": { + "max-line-length": { + "options": [132] + } }, "rulesDirectory": [ "node_modules/tslint-eslint-rules/dist/rules"