diff --git a/js/lang.js b/js/lang.js index fee99ec266..dc09c74f01 100644 --- a/js/lang.js +++ b/js/lang.js @@ -26,43 +26,19 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/  +const fs = require('fs'); +const nodePath = require('path'); +const PO = require('pofile'); +const os = require('os'); + if (process.argv.length < 2) { throw new Error('No dir argument passed'); } -const fs = require('fs'); -const nodePath = require('path'); - -const PO = require('pofile'); -const os = require('os'); - - -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); - } - } -} - - -/*var deleteFolderRecursive = function (path) { - var files = []; - if (fs.existsSync(path)) { - files = fs.readdirSync(path); - files.forEach(function(file,index){ - var curPath = path + "/" + file; - if(fs.lstatSync(curPath).isDirectory()) { - deleteFolderRecursive(curPath); - } else { - fs.unlinkSync(curPath); - } - }); - fs.rmdirSync(path); - } -};*/ +/** + * Builds language files from a PO file. + */ class Lang { constructor (language, poPath, espoPath, onlyModuleName) { diff --git a/lang.js b/lang.js index 0213077522..0b35c0f08c 100644 --- a/lang.js +++ b/lang.js @@ -26,6 +26,17 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/  +/** + * Builds language files from a PO file. + * + * Command example: `node lang de_DE`. + * + * A PO file should be located in `build` directory: `build/espocrm-lang_CODE.po`. + * Langugae files will be created in `build` directory. + * + * You specify a module with `--module=` parameter. It will build only for the specified module. + */ + const Lang = require('./js/lang'); const path = require('path'); const fs = require('fs'); @@ -59,22 +70,5 @@ if (!poPath) { poPath += '.po'; } -/*var deleteFolderRecursive = function (path) { - var files = []; - if (fs.existsSync(path)) { - files = fs.readdirSync(path); - files.forEach(function(file,index){ - var curPath = path + "/" + file; - if(fs.lstatSync(curPath).isDirectory()) { - deleteFolderRecursive(curPath); - } else { - fs.unlinkSync(curPath); - } - }); - fs.rmdirSync(path); - } -};*/ - - var lang = new Lang(language, poPath, espoPath, onlyModuleName); lang.run();