-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathCheckTranslations.spec.js
81 lines (76 loc) · 2.94 KB
/
CheckTranslations.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import _ from "lodash"
import ar_translations from "@/lang/ar"
import bik_translations from "@/lang/bik"
import ceb_translations from "@/lang/ceb"
import de_translations from "@/lang/de"
import en_translations from "@/lang/en"
import es_mx_translations from "@/lang/es-mx"
import fr_translations from "@/lang/fr"
import hi_translations from "@/lang/hi"
import id_translations from "@/lang/id"
import ilo_translations from "@/lang/ilo"
import it_translations from "@/lang/it"
import ja_translations from "@/lang/ja"
import ms_translations from "@/lang/ms"
import my_translations from "@/lang/my"
import nl_translations from "@/lang/nl"
import pl_translations from "@/lang/pl"
import pt_br_translations from "@/lang/pt-br"
import sv_translations from "@/lang/sv"
import ta_translations from "@/lang/ta"
import tl_translations from "@/lang/tl"
import ur_translations from "@/lang/ur"
import vi_translations from "@/lang/vi"
import zh_hans_translations from "@/lang/zh-hans"
import zh_hant_translations from "@/lang/zh-hant"
describe("Translations", () => {
describe.each([
["ar", "Arabic", ar_translations],
["bik", "Bikolano", bik_translations],
["ceb", "Bisaya", ceb_translations],
["de", "German", de_translations],
["es-mx", "Español", es_mx_translations],
["fr", "French", fr_translations],
["hi", "Hindi", hi_translations],
["id", "Bahasa Indonesia", id_translations],
["ilo", "Ilocano", ilo_translations],
["it", "Italian", it_translations],
["ja", "Japanese", ja_translations],
["ms", "Bahasa Melayu", ms_translations],
["my", "Burmese", my_translations],
["nl", "Nederlands", nl_translations],
["pl", "Polish", pl_translations],
["pt-br", "Portuguese", pt_br_translations],
["sv", "Svenska", sv_translations],
["ta", "Tamil", ta_translations],
["tl", "Tagalog", tl_translations],
["ur", "Urdu", ur_translations],
["vi", "Vietnamese", vi_translations],
["zh-hans", "Simplified Chinese", zh_hans_translations],
["zh-hant", "Traditional Chinese", zh_hant_translations]
])("in (%s) %s", (languageCode, languageName, languageTranslations) => {
test("should have the same number of translation entries", () => {
expect(_.keys(en_translations).length).toBe(
_.keys(languageTranslations).length
)
})
test("should have the same keys", () => {
_.each(en_translations, (value, key) => {
if (typeof value === "object") {
const objectKey = languageTranslations[key]
_.each(value, (value2, nestedKey) => {
if (!_.has(objectKey, nestedKey)) {
console.log(`[${languageCode}] Missing key:`, nestedKey)
}
expect(_.has(objectKey, nestedKey)).toBe(true)
})
} else {
if (!_.has(languageTranslations, key)) {
console.log(`[${languageCode}] Missing key:`, key)
}
expect(_.has(languageTranslations, key)).toBe(true)
}
})
})
})
})