po script improvement

This commit is contained in:
yuri
2018-10-16 13:42:11 +03:00
parent 720bdc7aaf
commit 756a913e94
2 changed files with 45 additions and 7 deletions

35
lang.js
View File

@@ -39,7 +39,20 @@ var isWin = /^win/.test(os.platform());
var espoPath = path.dirname(fs.realpathSync(__filename)) + '';
var resLang = process.argv[2] || 'lang_LANG';
var poPath = process.argv[3] || espoPath + '/build/' + 'espocrm-' + resLang +'.po';
var poPath = espoPath + '/build/' + 'espocrm-' + resLang +'.po';
var onlyModuleName = null;
if (process.argv.length > 2) {
for (var i in process.argv) {
if (~process.argv[i].indexOf('--module=')) {
onlyModuleName = process.argv[i].substr(('--module=').length);
}
if (~process.argv[i].indexOf('--path=')) {
poPath = process.argv[i].substr(('--path=').length);
}
}
}
var deleteFolderRecursive = function (path) {
var files = [];
@@ -68,6 +81,10 @@ function Lang (poPath, espoPath) {
this.currentPath = path.dirname(fs.realpathSync(__filename)) + '/';
this.moduleList = ['Crm'];
if (onlyModuleName) {
this.moduleList = [onlyModuleName];
}
this.baseLanguage = 'en_US';
var dirNames = this.dirNames = {};
@@ -78,12 +95,6 @@ function Lang (poPath, espoPath) {
var dirs = [coreDir];
dirNames[coreDir] = 'application/Espo/Resources/i18n/' + resLang + '/';
this.moduleList.forEach(function (moduleName) {
var dir = this.espoPath + 'application/Espo/Modules/' + moduleName + '/Resources/i18n/' + this.baseLanguage + '/';
dirs.push(dir);
dirNames[dir] = 'application/Espo/Modules/' + moduleName + '/Resources/i18n/' + resLang + '/';
}, this);
var installDir = this.espoPath + 'install/core/i18n/' + this.baseLanguage + '/';
dirs.push(installDir);
dirNames[installDir] = 'install/core/i18n/' + resLang + '/';
@@ -93,6 +104,16 @@ function Lang (poPath, espoPath) {
dirs.push(templatesDir);
dirNames[templatesDir] = 'application/Espo/Core/Templates/i18n/' + resLang + '/';
if (onlyModuleName) {
dirs = [];
}
this.moduleList.forEach(function (moduleName) {
var dir = this.espoPath + 'application/Espo/Modules/' + moduleName + '/Resources/i18n/' + this.baseLanguage + '/';
dirs.push(dir);
dirNames[dir] = 'application/Espo/Modules/' + moduleName + '/Resources/i18n/' + resLang + '/';
}, this);
this.dirs = dirs;
};

17
po.js
View File

@@ -37,8 +37,20 @@ var language = process.argv[2];
var espoPath = path.dirname(fs.realpathSync(__filename)) + '';
var onlyModuleName = null;
if (process.argv.length > 2) {
for (var i in process.argv) {
if (~process.argv[i].indexOf('--module=')) {
onlyModuleName = process.argv[i].substr(('--module=').length);
}
}
}
function PO (espoPath, language) {
this.moduleList = ['Crm'];
if (onlyModuleName) {
this.moduleList = [onlyModuleName];
}
this.baseLanguage = 'en_US';
this.language = language || this.baseLanguage;
@@ -56,6 +68,11 @@ function PO (espoPath, language) {
this.path + 'install/core/i18n/',
this.path + 'application/Espo/Core/Templates/i18n/'
];
if (onlyModuleName) {
dirs = [];
}
this.moduleList.forEach(function (moduleName) {
dirs.push(this.path + 'application/Espo/Modules/' + moduleName + '/Resources/i18n/');
}, this);