From c3c3e0838b67ada5d3183bcba729f4efd7cc2c22 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Wed, 17 Jul 2019 22:11:07 +0900
Subject: [PATCH] refs #964 Add a spec to check duplicate keys between
translation and missing json
---
spec/config/i18n.spec.ts | 18 ++++++++++++++++++
src/config/locales/en/translation.missing.json | 1 +
src/config/locales/ja/translation.missing.json | 1 +
3 files changed, 20 insertions(+)
diff --git a/spec/config/i18n.spec.ts b/spec/config/i18n.spec.ts
index 8f38ec67..a00babb1 100644
--- a/spec/config/i18n.spec.ts
+++ b/spec/config/i18n.spec.ts
@@ -24,4 +24,22 @@ describe('i18n', () => {
})
})
})
+
+ describe('should not define duplicate keys', () => {
+ locales.map(locale => {
+ it(`${locale} translation`, () => {
+ const targetJson = JSON.parse(
+ fs.readFileSync(path.resolve(__dirname, `../../src/config/locales/${locale}/translation.json`), 'utf8')
+ )
+ const targetMissingJson = JSON.parse(
+ fs.readFileSync(path.resolve(__dirname, `../../src/config/locales/${locale}/translation.missing.json`), 'utf8')
+ )
+ const allKeys = keys(targetJson).concat(keys(targetMissingJson))
+ const duplicates: Array = allKeys.filter(
+ (x: string, _: number, self: Array) => self.indexOf(x) !== self.lastIndexOf(x)
+ )
+ expect(duplicates).toEqual([])
+ })
+ })
+ })
})
diff --git a/src/config/locales/en/translation.missing.json b/src/config/locales/en/translation.missing.json
index e69de29b..0967ef42 100644
--- a/src/config/locales/en/translation.missing.json
+++ b/src/config/locales/en/translation.missing.json
@@ -0,0 +1 @@
+{}
diff --git a/src/config/locales/ja/translation.missing.json b/src/config/locales/ja/translation.missing.json
index e69de29b..0967ef42 100644
--- a/src/config/locales/ja/translation.missing.json
+++ b/src/config/locales/ja/translation.missing.json
@@ -0,0 +1 @@
+{}