mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-02-02 18:36:56 +01:00
refs #1106 Remove unsued spec which checks perfection of translation
This commit is contained in:
parent
0111f123de
commit
534736ea58
@ -1,40 +1,17 @@
|
|||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import keys from 'all-object-keys'
|
import keys from 'all-object-keys'
|
||||||
import objectAssignDeep from 'object-assign-deep'
|
|
||||||
|
|
||||||
const defaultLocale = 'en'
|
|
||||||
const locales = ['de', 'fr', 'it', 'ja', 'ko', 'pl', 'zh_cn']
|
const locales = ['de', 'fr', 'it', 'ja', 'ko', 'pl', 'zh_cn']
|
||||||
|
|
||||||
const enJson = JSON.parse(fs.readFileSync(path.resolve(__dirname, `../../src/config/locales/${defaultLocale}/translation.json`), 'utf8'))
|
|
||||||
|
|
||||||
describe('i18n', () => {
|
describe('i18n', () => {
|
||||||
describe('should be same 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 enKeys = keys(enJson)
|
|
||||||
const targetKeys = keys(objectAssignDeep(targetJson, targetMissingJson))
|
|
||||||
expect(enKeys.sort()).toEqual(targetKeys.sort())
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('should not define duplicate keys', () => {
|
describe('should not define duplicate keys', () => {
|
||||||
locales.map(locale => {
|
locales.map(locale => {
|
||||||
it(`${locale} translation`, () => {
|
it(`${locale} translation`, () => {
|
||||||
const targetJson = JSON.parse(
|
const targetJson = JSON.parse(
|
||||||
fs.readFileSync(path.resolve(__dirname, `../../src/config/locales/${locale}/translation.json`), 'utf8')
|
fs.readFileSync(path.resolve(__dirname, `../../src/config/locales/${locale}/translation.json`), 'utf8')
|
||||||
)
|
)
|
||||||
const targetMissingJson = JSON.parse(
|
const allKeys = keys(targetJson)
|
||||||
fs.readFileSync(path.resolve(__dirname, `../../src/config/locales/${locale}/translation.missing.json`), 'utf8')
|
|
||||||
)
|
|
||||||
const allKeys = keys(targetJson).concat(keys(targetMissingJson))
|
|
||||||
const duplicates: Array<string> = allKeys.filter(
|
const duplicates: Array<string> = allKeys.filter(
|
||||||
(x: string, _: number, self: Array<string>) => self.indexOf(x) !== self.lastIndexOf(x)
|
(x: string, _: number, self: Array<string>) => self.indexOf(x) !== self.lastIndexOf(x)
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user