UNPKG

rucken

Version:

Console tools and scripts for nx and not only that I (EndyKaufman) use to automate the workflow and speed up the development process

119 lines 5.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TranslateCommands = void 0; const tslib_1 = require("tslib"); const nestjs_console_1 = require("../../nestjs-console"); const extract_i18n_config_1 = require("../extract-i18n/extract-i18n.config"); const extract_i18n_service_1 = require("../extract-i18n/extract-i18n.service"); const gettext_config_1 = require("../gettext/gettext.config"); const gettext_service_1 = require("../gettext/gettext.service"); const utils_service_1 = require("../utils/utils.service"); let TranslateCommands = class TranslateCommands { gettextService; extracti18nService; utilsService; extracti18nConfig = {}; gettextConfig = {}; constructor(gettextService, extracti18nService, utilsService) { this.gettextService = gettextService; this.extracti18nService = extracti18nService; this.utilsService = utilsService; this.extracti18nConfig = this.utilsService.getRuckenConfig(extract_i18n_config_1.DEFAULT_EXTRACT_I18N_CONFIG).extracti18n; this.gettextConfig = this.utilsService.getRuckenConfig(gettext_config_1.DEFAULT_GETTEXT_CONFIG).gettext; } async translate({ defaultLocale, locales, resetUnusedTranslates, clientProjectNameParts, e2eProjectNameParts, serverProjectNameParts, }) { const resetUnusedTranslatesBoolean = (resetUnusedTranslates || this.gettextConfig.resetUnusedTranslates || 'false').toLowerCase() === 'true'; this.extracti18nService.setLogger(`prepare: ${extract_i18n_service_1.Extracti18nService.title}`); this.gettextService.setLogger(`prepare: ${gettext_service_1.GettextService.title}`); if (resetUnusedTranslatesBoolean) { await this.gettextService.extractTranslatesFromSourcesForLibraries({ po2jsonOptions: this.gettextConfig.po2jsonOptions, pattern: this.gettextConfig.gettextExtractorOptions?.pattern, locales: locales ? locales.split(',') : this.gettextConfig.locales, defaultLocale: defaultLocale || this.gettextConfig.defaultLocale, markers: this.gettextConfig.markers, }); } this.extracti18nService.extract({ locales: locales ? locales.split(',') : this.extracti18nConfig.locales, markers: this.extracti18nConfig.markers, resetUnusedTranslates: resetUnusedTranslatesBoolean, clientProjectNameParts: clientProjectNameParts?.split(',') || this.extracti18nConfig.clientProjectNameParts, e2eProjectNameParts: e2eProjectNameParts?.split(',') || this.extracti18nConfig.e2eProjectNameParts, serverProjectNameParts: serverProjectNameParts?.split(',') || this.extracti18nConfig.serverProjectNameParts, }); await this.gettextService.extractTranslatesFromSourcesForLibraries({ po2jsonOptions: this.gettextConfig.po2jsonOptions, pattern: this.gettextConfig.gettextExtractorOptions?.pattern, locales: locales ? locales.split(',') : this.gettextConfig.locales, defaultLocale: defaultLocale || this.gettextConfig.defaultLocale, markers: this.gettextConfig.markers, }); this.extracti18nService.extract({ locales: locales ? locales.split(',') : this.extracti18nConfig.locales, markers: this.extracti18nConfig.markers, resetUnusedTranslates: resetUnusedTranslatesBoolean, noExtract: true, clientProjectNameParts: clientProjectNameParts?.split(',') || this.extracti18nConfig.clientProjectNameParts, e2eProjectNameParts: e2eProjectNameParts?.split(',') || this.extracti18nConfig.e2eProjectNameParts, serverProjectNameParts: serverProjectNameParts?.split(',') || this.extracti18nConfig.serverProjectNameParts, }); } }; exports.TranslateCommands = TranslateCommands; tslib_1.__decorate([ (0, nestjs_console_1.Command)({ command: 'translate', description: 'extract translate from source (run: extract-i18n => gettext => extract-i18n)', options: [ { flags: '-l,--locales [strings]', description: 'list of available languages (example: ru,en)', }, { flags: '--default-locale [string]', description: 'default locale (default: en)', }, { flags: '--reset-unused-translates [boolean]', description: 'remove all translates if they not found in source code (default: true)', defaultValue: 'true', }, { flags: '--e2e-project-name-parts [string]', }, { flags: '--client-project-name-parts [string]', }, { flags: '--server-project-name-parts [string]', }, ], }), tslib_1.__metadata("design:type", Function), tslib_1.__metadata("design:paramtypes", [Object]), tslib_1.__metadata("design:returntype", Promise) ], TranslateCommands.prototype, "translate", null); exports.TranslateCommands = TranslateCommands = tslib_1.__decorate([ (0, nestjs_console_1.Console)(), tslib_1.__metadata("design:paramtypes", [gettext_service_1.GettextService, extract_i18n_service_1.Extracti18nService, utils_service_1.UtilsService]) ], TranslateCommands); //# sourceMappingURL=translate.commands.js.map