MOBILE-2308 gulp: Adapt gulp language files creation

main
Pau Ferrer Ocaña 2017-12-20 15:36:51 +01:00
parent 6e899ad5a8
commit 9aa07fbab0
4 changed files with 44 additions and 36 deletions

View File

@ -59,39 +59,39 @@ function treatMergedData(data) {
var mergedOrdered = {}; var mergedOrdered = {};
for (var filepath in data) { 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) { // For subplugins. We'll use plugin_subfolder_subfolder2_...
// E.g. 'mod_assign_feedback_comments'.
var componentName = filepath.replace('core/', ''); prefix = 'addon.' + pathSplit.join('_');
componentName = componentName.substr(0, componentName.indexOf('/')); break;
addProperties(merged, data[filepath], 'core.'+componentName+'.'); case 'assets':
prefix = 'assets.' + pathSplit[1];
} else if (filepath.indexOf('addons') === 0) { break;
}
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-');
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: [ lang: [
'./src/lang/', './src/lang/',
'./src/core/**/lang/', './src/core/**/lang/',
'./src/addons/**/lang/', './src/addon/**/lang/',
'./src/assets/countries/', './src/assets/countries/',
'./src/assets/mimetypes/' './src/assets/mimetypes/'
], ],

View File

@ -323,7 +323,7 @@ export class CoreMimetypeUtilsProvider {
let filename = '', let filename = '',
mimetype = '', mimetype = '',
extension = '', extension = '',
langPrefix = 'core.mimetype-'; langPrefix = 'assets.mimetypes.';
if (typeof obj == 'object' && typeof obj.file == 'function') { 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. // 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. * @return {string} Translated name.
*/ */
getTranslatedGroupName(name: string) : string { getTranslatedGroupName(name: string) : string {
let key = 'core.mimetype-group:' + name, let key = 'assets.mimetypes.group:' + name,
translated = this.translate.instant(key); translated = this.translate.instant(key);
return translated != key ? translated : name; return translated != key ? translated : name;
} }

View File

@ -552,7 +552,7 @@ export class CoreUtilsProvider {
* @return {string} Country name. If the country is not found, return the country code. * @return {string} Country name. If the country is not found, return the country code.
*/ */
getCountryName(code: string) : string { getCountryName(code: string) : string {
let countryKey = 'core.country-' + code, let countryKey = 'assets.countries.' + code,
countryName = this.translate.instant(countryKey); countryName = this.translate.instant(countryKey);
return countryName !== countryKey ? countryName : code; return countryName !== countryKey ? countryName : code;
@ -580,8 +580,8 @@ export class CoreUtilsProvider {
let countries = {}; let countries = {};
for (let name in table) { for (let name in table) {
if (name.indexOf('core.country-') === 0) { if (name.indexOf('assets.countries.') === 0) {
let code = name.replace('core.country-', ''); let code = name.replace('assets.countries.', '');
countries[code] = table[name]; countries[code] = table[name];
} }
} }

View File

@ -3,7 +3,15 @@
"no-duplicate-variable": true, "no-duplicate-variable": true,
"no-unused-variable": [ "no-unused-variable": [
true true
] ],
"max-line-length": {
"options": [132]
},
},
"jsRules": {
"max-line-length": {
"options": [132]
}
}, },
"rulesDirectory": [ "rulesDirectory": [
"node_modules/tslint-eslint-rules/dist/rules" "node_modules/tslint-eslint-rules/dist/rules"