-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #264 from BorisTB/master
Support keyPrefix
- Loading branch information
Showing
12 changed files
with
107 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import i18next from "i18next"; | ||
|
||
export function anyJSFunction1() { | ||
const t = i18next.getFixedT(null, 'ns0', 'deep0'); | ||
t('key0'); | ||
} | ||
|
||
export function anyJSFunction2() { | ||
const t = i18next.getFixedT(null, 'ns1', 'deep1.deep2'); | ||
|
||
t('key1'); | ||
} | ||
|
||
export function anyJSFunction3() { | ||
const t = i18next.getFixedT(null, 'ns2', 'deep3.deep4'); | ||
|
||
t('key2.key3'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"description": "test keyPrefix usage of getFixedT TFunction", | ||
"pluginOptions": {}, | ||
"expectValues": [ | ||
[{"deep0": { "key0": "" }}, {"ns": "ns0"}], | ||
[{"deep1": { "deep2": { "key1": "" }}}, {"ns": "ns1"}], | ||
[{"deep3": { "deep4": { "key2": { "key3": "" } }}}, {"ns": "ns2"}] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
export function MyComponent1() { | ||
const [t] = useTranslation('ns0', { keyPrefix: 'deep0' }); | ||
return <p>{t('key0')}{t('key1')}</p> | ||
} | ||
|
||
export function MyComponent2() { | ||
const [t] = useTranslation('ns1', { keyPrefix: 'deep1.deep2' }); | ||
return <p>{t('key2')}{t('key3')}</p> | ||
} | ||
|
||
export function MyComponent3() { | ||
const [t] = useTranslation('ns2', { keyPrefix: 'deep3.deep4' }); | ||
return <p>{t('key4.key5')}{t('key4.key6')}</p> | ||
} | ||
|
||
export function MyComponent4() { | ||
const [t] = useTranslation('ns3', { keyPrefix: 'deep5.deep6' }); | ||
return <p>{t('key7.key8')}{t('key9.key10')}</p> | ||
} | ||
|
||
export function MyComponent5() { | ||
const [t] = useTranslation('ns4', { keyPrefix: 'deep7.deep8' }); | ||
return <p>{t('ns5:key11')}</p> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"description": "test keyPrefix extraction of useTranslation hook", | ||
"pluginOptions": {}, | ||
"expectValues": [ | ||
[{ "deep0": {"key0": "", "key1": ""}}, {"ns": "ns0"}], | ||
[{ "deep1": {"deep2": {"key2": "", "key3": ""}}}, {"ns": "ns1"}], | ||
[{ "deep3": {"deep4": {"key4": { "key5": "", "key6": "" }}}}, {"ns": "ns2"}], | ||
[{ "deep5": {"deep6": {"key7": { "key8": "" }, "key9": {"key10": ""}}}}, {"ns": "ns3"}], | ||
[{ "key11": ""}, {"ns": "deep7.deep8.ns5"}] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"key0": "", | ||
"key1": "", | ||
"key2": "", | ||
"key3": { "key4": "" }, | ||
"from wildcard import": "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters