Merge branch 'develop' into new-guest-access
This commit is contained in:
commit
a92d96347b
59 changed files with 2009 additions and 386 deletions
1
scripts/check-i18n.pl
Symbolic link
1
scripts/check-i18n.pl
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../matrix-react-sdk/scripts/check-i18n.pl
|
|
@ -3,6 +3,23 @@
|
|||
// copies the resources into the webapp directory.
|
||||
//
|
||||
|
||||
// Languages are listed manually so we can choose when to include
|
||||
// a translation in the app (because having a translation with only
|
||||
// 3 strings translated is just frustrating)
|
||||
// This could readily be automated, but it's nice to explicitly
|
||||
// control when we languages are available.
|
||||
const INCLUDE_LANGS = [
|
||||
//'be' Omitted because no translations in react-sdk
|
||||
'en_EN',
|
||||
'da',
|
||||
'de_DE',
|
||||
'fr',
|
||||
'be',
|
||||
'pt',
|
||||
'pt_BR',
|
||||
'ru',
|
||||
];
|
||||
|
||||
// cpx includes globbed parts of the filename in the destination, but excludes
|
||||
// common parents. Hence, "res/{a,b}/**": the output will be "dest/a/..." and
|
||||
// "dest/b/...".
|
||||
|
@ -14,12 +31,20 @@ const COPY_LIST = [
|
|||
["src/skins/vector/{fonts,img}/**", "webapp"],
|
||||
["node_modules/emojione/assets/svg/*", "webapp/emojione/svg/"],
|
||||
["node_modules/emojione/assets/png/*", "webapp/emojione/png/"],
|
||||
["./config.json", "webapp", {directwatch: 1}],
|
||||
["./config.json", "webapp", { directwatch: 1 }],
|
||||
];
|
||||
|
||||
INCLUDE_LANGS.forEach(function(l) {
|
||||
COPY_LIST.push([
|
||||
l, "webapp/i18n/", { lang: 1 },
|
||||
]);
|
||||
});
|
||||
|
||||
const parseArgs = require('minimist');
|
||||
const Cpx = require('cpx');
|
||||
const chokidar = require('chokidar');
|
||||
const fs = require('fs');
|
||||
const rimraf = require('rimraf');
|
||||
|
||||
const argv = parseArgs(
|
||||
process.argv.slice(2), {}
|
||||
|
@ -35,6 +60,15 @@ function errCheck(err) {
|
|||
}
|
||||
}
|
||||
|
||||
// Check if webapp exists
|
||||
if (!fs.existsSync('webapp')) {
|
||||
fs.mkdirSync('webapp');
|
||||
}
|
||||
// Check if i18n exists
|
||||
if (!fs.existsSync('webapp/i18n/')) {
|
||||
fs.mkdirSync('webapp/i18n/');
|
||||
}
|
||||
|
||||
function next(i, err) {
|
||||
errCheck(err);
|
||||
|
||||
|
@ -46,10 +80,13 @@ function next(i, err) {
|
|||
const source = ent[0];
|
||||
const dest = ent[1];
|
||||
const opts = ent[2] || {};
|
||||
let cpx = undefined;
|
||||
|
||||
const cpx = new Cpx.Cpx(source, dest);
|
||||
if (!opts.lang) {
|
||||
cpx = new Cpx.Cpx(source, dest);
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
if (verbose && cpx) {
|
||||
cpx.on("copy", (event) => {
|
||||
console.log(`Copied: ${event.srcPath} --> ${event.dstPath}`);
|
||||
});
|
||||
|
@ -58,7 +95,7 @@ function next(i, err) {
|
|||
});
|
||||
}
|
||||
|
||||
const cb = (err) => {next(i+1, err)};
|
||||
const cb = (err) => { next(i + 1, err) };
|
||||
|
||||
if (watch) {
|
||||
if (opts.directwatch) {
|
||||
|
@ -66,20 +103,74 @@ function next(i, err) {
|
|||
// which in the case of config.json is '.', which inevitably takes
|
||||
// ages to crawl. So we create our own watcher on the files
|
||||
// instead.
|
||||
const copy = () => {cpx.copy(errCheck)};
|
||||
const copy = () => { cpx.copy(errCheck) };
|
||||
chokidar.watch(source)
|
||||
.on('add', copy)
|
||||
.on('change', copy)
|
||||
.on('ready', cb)
|
||||
.on('error', errCheck);
|
||||
} else if (opts.lang) {
|
||||
const reactSdkFile = 'node_modules/matrix-react-sdk/src/i18n/strings/' + source + '.json';
|
||||
const riotWebFile = 'src/i18n/strings/' + source + '.json';
|
||||
|
||||
const translations = {};
|
||||
const makeLang = () => { genLangFile(source, dest) };
|
||||
[reactSdkFile, riotWebFile].forEach(function(f) {
|
||||
chokidar.watch(f)
|
||||
.on('add', makeLang)
|
||||
.on('change', makeLang)
|
||||
//.on('ready', cb) We'd have to do this when both files are ready
|
||||
.on('error', errCheck);
|
||||
});
|
||||
next(i + 1, err);
|
||||
} else {
|
||||
cpx.on('watch-ready', cb);
|
||||
cpx.on("watch-error", cb);
|
||||
cpx.watch();
|
||||
}
|
||||
} else if (opts.lang) {
|
||||
genLangFile(source, dest);
|
||||
next(i + 1, err);
|
||||
} else {
|
||||
cpx.copy(cb);
|
||||
}
|
||||
}
|
||||
|
||||
function genLangFile(lang, dest) {
|
||||
const reactSdkFile = 'node_modules/matrix-react-sdk/src/i18n/strings/' + lang + '.json';
|
||||
const riotWebFile = 'src/i18n/strings/' + lang + '.json';
|
||||
|
||||
const translations = {};
|
||||
[reactSdkFile, riotWebFile].forEach(function(f) {
|
||||
if (fs.existsSync(f)) {
|
||||
Object.assign(
|
||||
translations,
|
||||
JSON.parse(fs.readFileSync(f).toString())
|
||||
);
|
||||
}
|
||||
});
|
||||
fs.writeFileSync(dest + lang + '.json', JSON.stringify(translations, null, 4));
|
||||
if (verbose) {
|
||||
console.log("Generated language file: " + lang);
|
||||
}
|
||||
}
|
||||
|
||||
function genLangList() {
|
||||
const languages = {};
|
||||
INCLUDE_LANGS.forEach(function(lang) {
|
||||
const normalizedLanguage = lang.toLowerCase().replace("_", "-");
|
||||
const languageParts = normalizedLanguage.split('-');
|
||||
if (languageParts.length == 2 && languageParts[0] == languageParts[1]) {
|
||||
languages[languageParts[0]] = lang + '.json';
|
||||
} else {
|
||||
languages[normalizedLanguage] = lang + '.json';
|
||||
}
|
||||
});
|
||||
fs.writeFile('webapp/i18n/languages.json', JSON.stringify(languages, null, 4));
|
||||
if (verbose) {
|
||||
console.log("Generated language list");
|
||||
}
|
||||
}
|
||||
|
||||
genLangList();
|
||||
next(0);
|
||||
|
|
|
@ -40,11 +40,13 @@ dodep matrix-org matrix-react-sdk
|
|||
mkdir -p node_modules
|
||||
cd node_modules
|
||||
|
||||
rm -r matrix-js-sdk 2> /dev/null
|
||||
ln -s ../matrix-js-sdk ./
|
||||
pushd matrix-js-sdk
|
||||
npm install
|
||||
popd
|
||||
|
||||
rm -r matrix-react-sdk 2> /dev/null
|
||||
ln -s ../matrix-react-sdk ./
|
||||
pushd matrix-react-sdk
|
||||
mkdir -p node_modules
|
||||
|
|
|
@ -34,11 +34,9 @@ npm run lintall -- -f checkstyle -o eslint.xml || true
|
|||
|
||||
rm dist/riot-*.tar.gz || true # rm previous artifacts without failing if it doesn't exist
|
||||
|
||||
# node_modules deps from 'npm install' don't have a .git dir so can't
|
||||
# rev-parse; but they do set the commit in package.json under 'gitHead' which
|
||||
# we're grabbing here.
|
||||
REACT_SHA=$(grep 'gitHead' node_modules/matrix-react-sdk/package.json | cut -d \" -f 4 | head -c 12)
|
||||
JSSDK_SHA=$(grep 'gitHead' node_modules/matrix-js-sdk/package.json | cut -d \" -f 4 | head -c 12)
|
||||
# Since the deps are fetched from git, we can rev-parse
|
||||
REACT_SHA=$(cd node_modules/matrix-react-sdk; git rev-parse --short=12 HEAD)
|
||||
JSSDK_SHA=$(cd node_modules/matrix-js-sdk; git rev-parse --short=12 HEAD)
|
||||
|
||||
VECTOR_SHA=$(git rev-parse --short=12 HEAD) # use the ACTUAL SHA rather than assume develop
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue