MOBILE-2308 gulp: Adapt gulp language files creation
parent
6e899ad5a8
commit
9aa07fbab0
58
gulpfile.js
58
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.');
|
||||
|
||||
} 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++;
|
||||
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];
|
||||
}
|
||||
addProperties(merged, data[filepath], 'mma.'+pluginName+'.');
|
||||
break;
|
||||
case 'addon':
|
||||
// Remove final item 'lang'.
|
||||
pathSplit.pop();
|
||||
// Remove first item 'addon'.
|
||||
pathSplit.shift();
|
||||
|
||||
} 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/'
|
||||
],
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
10
tslint.json
10
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"
|
||||
|
|
Loading…
Reference in New Issue