-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UPSTREAM CHANGES] latest changes as of Mon Jun 27 2022 00:14:19 GMT+…
…0000 (Coordinated Universal Time) (#97) * Mark which modules to preload, prevents loading unnecessary modules such as the subscription module when subscriptions aren't enabled Fixes #220 * Update packages * Resolve "Internationalization support" * Apparently we can't override docker build args Co-authored-by: David Burke <david@burkesoftware.com> Co-authored-by: james kiger <james.kiger@gmail.com> Co-authored-by: GH Action - Upstream Sync <action@github.com>
- Loading branch information
1 parent
080206f
commit 446626e
Showing
33 changed files
with
3,753 additions
and
716 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
bin/xliff-to-json/xliff-to-json src/locale/ | ||
mv src/locale/*.json src/assets/i18n/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
const xliff2js = require('xliff/xliff2js'); | ||
const targetOfjs = require('xliff/targetOfjs'); | ||
const utils = require('./utils'); | ||
|
||
// function to find all files in a directory with a specific extension | ||
function findByExt(base,exts,files,result) | ||
{ | ||
files = files || fs.readdirSync(base) | ||
result = result || [] | ||
|
||
files.forEach( | ||
function (file) { | ||
var newbase = path.join(base,file) | ||
if (!fs.statSync(newbase).isDirectory()) | ||
{ | ||
for (let i = 0; i < exts.length; i++) { | ||
const ext = exts[i]; | ||
if ( file.substr(-1*(ext.length+1)) == '.' + ext ) | ||
{ | ||
result.push(newbase); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
) | ||
return result | ||
} | ||
|
||
async function convert(input_path) { | ||
if (!input_path) { | ||
return; | ||
} | ||
|
||
if (!fs.existsSync(input_path)) { | ||
console.log(`ERROR: File or directory "${input_path}" not found!`); | ||
return; | ||
} | ||
|
||
const is_dir = fs.lstatSync(input_path).isDirectory(); | ||
|
||
let files = null; | ||
|
||
if (is_dir) { | ||
// gets all files in input with extension 'xlf' or 'xliff' | ||
files = findByExt(input_path, ['xlf', 'xliff']); | ||
} else { | ||
files = [input_path]; | ||
} | ||
|
||
if (files.length === 0) { | ||
console.log(`ERROR: No files found in "${input_path}"!`); | ||
return; | ||
} | ||
|
||
for (let i = 0; i < files.length; i++) { | ||
let file = files[i]; | ||
let base_file_name = file.replace(/^.*[\\\/]/, ''); | ||
|
||
let file_info = fs.readFileSync(file, 'utf8'); | ||
|
||
// getting data | ||
const json_obj = await xliff2js(file_info); | ||
|
||
// got data, now convert to JSON | ||
const res = targetOfjs(json_obj); | ||
const string_res = JSON.stringify(res, null, 2); | ||
|
||
// writes new JSON file | ||
const new_path = path.join(is_dir ? input_path : path.dirname(input_path), base_file_name.substring(0, base_file_name.length - 3) + 'json'); | ||
if (fs.existsSync(new_path)) { | ||
const old_file = fs.readFileSync(new_path, 'utf8'); | ||
if (old_file === string_res) { | ||
console.log(`INFO: Skipping converting "${file}" to "${new_path}" as the output is equivalent.`); | ||
} else { | ||
console.log(`INFO: Overwriting "${file}" with "${new_path}".`); | ||
} | ||
} else { | ||
fs.writeFileSync(new_path, string_res); | ||
console.log(`INFO: Converted "${file}" to "${new_path}".`); | ||
} | ||
} | ||
} | ||
|
||
if (require.main === module) { | ||
const input_path = utils.getPath(false); | ||
convert(input_path); | ||
} | ||
|
||
module.exports = { | ||
convert: convert | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
exports.getPath = (using_npm) => { | ||
const args_start_index = using_npm ? 2 : 2; | ||
let input_path = null; | ||
const args = process.argv; | ||
switch (args.length) { | ||
case args_start_index: | ||
input_path = process.cwd(); | ||
console.log('INFO: File or directory not specified, defaulting to current directory.'); | ||
break; | ||
case args_start_index + 1: | ||
input_path = args[args_start_index]; | ||
break; | ||
default: | ||
const base_command = using_npm ? 'xliff-to-json' : 'node app.js' | ||
console.log(`ERROR: Args count mismatch! Usage is: ${base_command} [file or directory]`) | ||
return null; | ||
} | ||
return input_path; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env node | ||
|
||
const app = require('./app'); | ||
const utils = require('./utils'); | ||
|
||
const dir = utils.getPath(true); | ||
app.convert(dir); |
Oops, something went wrong.