Skip to content

Commit fdeb304

Browse files
authored
chore(use-i18n): move example tests file to json (#592)
1 parent 7b1860d commit fdeb304

File tree

8 files changed

+26
-25
lines changed

8 files changed

+26
-25
lines changed

packages/use-i18n/src/__tests__/locales/en.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"plurals":
3+
"You have {numPhotos, plural, =0 {no photos.} =1 {one photo.} other {# photos.}}",
4+
"subtitle": "Here is a subtitle",
5+
"tests.test.namespaces": "test",
6+
"title": "Welcome on @scaelway/ui i18n hook"
7+
}

packages/use-i18n/src/__tests__/locales/es.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"plurals":
3+
"You have {numPhotos, plural, =0 {no photos.} =1 {one photo.} other {# photos.}}",
4+
"subtitle": "Aquí hay un subtítulo",
5+
"tests.test.namespaces": "test",
6+
"title": "Bienvenido @scaelway/ui i18n hook"
7+
}

packages/use-i18n/src/__tests__/locales/fr.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"plurals":
3+
"You have {numPhotos, plural, =0 {no photos.} =1 {one photo.} other {# photos.}}",
4+
"subtitle": "Voici un sous-titre",
5+
"tests.test.namespaces": "test",
6+
"title": "Bienvenue sur @scaelway/ui i18n hook"
7+
}

packages/use-i18n/src/__tests__/usei18n.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import { act, renderHook } from '@testing-library/react-hooks'
22
import mockdate from 'mockdate'
33
import React from 'react'
44
import I18n, { useI18n, useTranslation } from '..'
5-
import en from './locales/en'
6-
import es from './locales/es'
7-
import fr from './locales/fr'
5+
import en from './locales/en.json'
6+
import es from './locales/es.json'
7+
import fr from './locales/fr.json'
88

99
const LOCALE_ITEM_STORAGE = 'locales'
1010

1111
const wrapper =
1212
({
1313
loadDateLocale = async (locale: string) => import(`date-fns/locale/${locale}/index`),
14-
defaultLoad = async ({ locale }: { locale: string }) => import(`./locales/${locale}`),
14+
defaultLoad = async ({ locale }: { locale: string }) => import(`./locales/${locale}.json`),
1515
defaultLocale = 'en',
1616
defaultTranslations = {},
1717
enableDebugKey = false,

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"moduleResolution": "node",
1313
"esModuleInterop": true,
1414
"allowSyntheticDefaultImports": true,
15+
"resolveJsonModule": true,
1516
"jsx": "preserve",
1617
},
1718
"include": ["**/*.ts", "**/*.js", "**/.*.js", "**/*.tsx"]

0 commit comments

Comments
 (0)