Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gerceker committed Aug 7, 2023
1 parent ed7cb2e commit d850b33
Show file tree
Hide file tree
Showing 13 changed files with 252 additions and 234 deletions.
2 changes: 2 additions & 0 deletions bin/cli/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var get_the_config_1 = require("../utils/get-the-config");
var validate_config_1 = require("../utils/validate-config");
var read_lang_files_1 = require("../functions/read-lang-files");
var fs_1 = require("fs");
var log_message_1 = require("../utils/log-message");
function compile(option) {
return __awaiter(this, void 0, void 0, function () {
var config_file, config, status, result;
Expand All @@ -57,6 +58,7 @@ function compile(option) {
return [4 /*yield*/, (0, read_lang_files_1.read_lang_files)(config)];
case 1:
result = _a.sent();
(0, log_message_1.log_message)('success', 'compiling_successfully', { output_file: config['output-file'] });
(0, fs_1.writeFileSync)(process.cwd() + '/' + config['output-file'], JSON.stringify(result));
return [2 /*return*/];
}
Expand Down
2 changes: 1 addition & 1 deletion bin/functions/read-lang-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function read_lang_files(config) {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
file = "".concat(input_dir, "/").concat(name, "/").concat(lang, ".json");
file = "".concat(input_dir, "/").concat(config['files'][name], "/").concat(lang, ".json");
return [4 /*yield*/, (0, json_parse_1.json_parse)(file)];
case 1:
data = _a.sent();
Expand Down
10 changes: 9 additions & 1 deletion bin/utils/log-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ var messages = {
config_is_invalid_json: "Config is not in a valid JSON format.",
required_config_option_is_not_assigned: "A required config property is not assigned. Unassigned value: {value}",
required_config_option_is_assigned_invalid_type: "The property is assigned an incorrect type. Incorrect value: {value}"
},
success: {
compiling_successfully: "Compiled successfully. Output file: {output_file}"
}
};
function assign_values(msg, values) {
Expand Down Expand Up @@ -76,7 +79,12 @@ function log_message(type, message, values) {
msg = _a.sent();
_a.label = 2;
case 2:
console.log(prefix + ' ' + chalk.red(msg));
if (type == 'error') {
console.log(prefix + ' ' + chalk.red(msg));
}
if (type == 'success') {
console.log(prefix + ' ' + chalk.green(msg));
}
_a.label = 3;
case 3: return [2 /*return*/];
}
Expand Down
3 changes: 3 additions & 0 deletions i18n/messages/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"test":"b"
}
3 changes: 3 additions & 0 deletions i18n/messages/tr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"test":"a"
}
3 changes: 1 addition & 2 deletions localize.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"input-dir": "i18n",
"output-file": "output.json",
"files": {
"messages": "messages",
"text": "text"
"messages": "messages"
},
"schema": "schema.json",
"global": true
Expand Down
198 changes: 99 additions & 99 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 1 addition & 12 deletions output.json
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
{
"en": {
"text": {
"test": "hello"
}
},
"tr": {
"text": {
"test": "merhaba"
}
}
}
{"en":{"messages":{"test":"b"}},"tr":{"messages":{"test":"a"}}}
Loading

0 comments on commit d850b33

Please sign in to comment.