From f6af464ffff8e49cd58978ca095da538dca3ad27 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 11 Jul 2019 09:39:22 -0600 Subject: [PATCH 1/3] Verify i18n in CI To protect developers from mistakes such as missing strings or getting them out of order. --- .buildkite/pipeline.yaml | 9 +++++++++ package.json | 1 + scripts/compare-file.js | 10 ++++++++++ 3 files changed, 20 insertions(+) create mode 100644 scripts/compare-file.js diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml index e918466e6f..05f7888106 100644 --- a/.buildkite/pipeline.yaml +++ b/.buildkite/pipeline.yaml @@ -85,6 +85,15 @@ steps: image: "node:10" propagate-environment: true + - label: "🌐 i18n" + command: + # Do the things needed to actually run the i18n stuff + - "yarn install" + - "yarn diff-i18n" + plugins: + - docker#v3.0.1: + image: "node:10" + - wait - label: "🐴 Trigger riot-web" diff --git a/package.json b/package.json index 006fb10138..b718b4c13e 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "rethemendex": "res/css/rethemendex.sh", "i18n": "matrix-gen-i18n", "prunei18n": "matrix-prune-i18n", + "diff-i18n": "cp src/i18n/strings/en_EN.json src/i18n/strings/en_EN_orig.json && ./scripts/gen-i18n.js && node scripts/compare-file.js src/i18n/strings/en_EN_orig.json src/i18n/strings/en_EN.json", "build": "yarn reskindex && yarn start:init", "build:watch": "babel src -w --skip-initial-build -d lib --source-maps --copy-files", "emoji-data-strip": "node scripts/emoji-data-strip.js", diff --git a/scripts/compare-file.js b/scripts/compare-file.js new file mode 100644 index 0000000000..f53275ebfa --- /dev/null +++ b/scripts/compare-file.js @@ -0,0 +1,10 @@ +const fs = require("fs"); + +if (process.argv.length < 4) throw new Error("Missing source and target file arguments"); + +const sourceFile = fs.readFileSync(process.argv[2], 'utf8'); +const targetFile = fs.readFileSync(process.argv[3], 'utf8'); + +if (sourceFile !== targetFile) { + throw new Error("Files do not match"); +} From b52b420b1f22e3c29a6abb9f508d2842bd0a749c Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 11 Jul 2019 12:39:26 -0600 Subject: [PATCH 2/3] Fix i18n --- src/i18n/strings/en_EN.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 449c6ce6bc..7a6f99b18f 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -202,8 +202,8 @@ "%(targetName)s rejected the invitation.": "%(targetName)s rejected the invitation.", "%(targetName)s left the room.": "%(targetName)s left the room.", "%(senderName)s unbanned %(targetName)s.": "%(senderName)s unbanned %(targetName)s.", - "%(senderName)s kicked %(targetName)s.": "%(senderName)s kicked %(targetName)s.", "%(senderName)s withdrew %(targetName)s's invitation.": "%(senderName)s withdrew %(targetName)s's invitation.", + "%(senderName)s kicked %(targetName)s.": "%(senderName)s kicked %(targetName)s.", "%(senderDisplayName)s changed the topic to \"%(topic)s\".": "%(senderDisplayName)s changed the topic to \"%(topic)s\".", "%(senderDisplayName)s removed the room name.": "%(senderDisplayName)s removed the room name.", "%(senderDisplayName)s changed the room name to %(roomName)s.": "%(senderDisplayName)s changed the room name to %(roomName)s.", From 40b5b784a39f3f5fa4c8be9ad6dcaa02de52fbec Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 11 Jul 2019 12:49:08 -0600 Subject: [PATCH 3/3] Break out into sections --- .buildkite/pipeline.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml index 05f7888106..af55fe8cb4 100644 --- a/.buildkite/pipeline.yaml +++ b/.buildkite/pipeline.yaml @@ -87,8 +87,9 @@ steps: - label: "🌐 i18n" command: - # Do the things needed to actually run the i18n stuff + - "echo '--- Fetching Dependencies'" - "yarn install" + - "echo '+++ Testing i18n output'" - "yarn diff-i18n" plugins: - docker#v3.0.1: