-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b93be8e
commit 4874059
Showing
60 changed files
with
204 additions
and
23,013 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ npm-debug.log* | |
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
.eslintcache | ||
package-lock.json |
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
31 changes: 13 additions & 18 deletions
31
...act-typescript4.1/namespaces/package.json → ...ript/simple-multi-namespaces/package.json
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
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
example/react-typescript/simple-multi-namespaces/src/@types/i18next.d.ts
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,8 @@ | ||
import { resources, defaultNS } from '../i18n/config'; | ||
|
||
declare module 'i18next' { | ||
interface CustomTypeOptions { | ||
defaultNS: typeof defaultNS; | ||
resources: typeof resources['en']; | ||
} | ||
} |
File renamed without changes.
16 changes: 16 additions & 0 deletions
16
example/react-typescript/simple-multi-namespaces/src/App.tsx
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,16 @@ | ||
import './i18n/config'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
function App() { | ||
const {t} = useTranslation(); | ||
|
||
return ( | ||
<div className="App"> | ||
<p>{t('title')}</p> | ||
<p>{t('description.part1')}</p> | ||
<p>{t('description.part2')}</p> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
15 changes: 15 additions & 0 deletions
15
example/react-typescript/simple-multi-namespaces/src/components/Comp1.tsx
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,15 @@ | ||
import { useTranslation } from "react-i18next"; | ||
|
||
function Comp1() { | ||
const {t} = useTranslation(); | ||
|
||
return ( | ||
<div className="App"> | ||
<p>{t('title')}</p> | ||
<p>{t('description.part1')}</p> | ||
<p>{t('description.part2')}</p> | ||
</div> | ||
); | ||
} | ||
|
||
export default Comp1; |
14 changes: 14 additions & 0 deletions
14
example/react-typescript/simple-multi-namespaces/src/components/Comp2.tsx
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,14 @@ | ||
import { useTranslation } from "react-i18next"; | ||
|
||
function Comp2() { | ||
const {t} = useTranslation('ns2'); | ||
|
||
return ( | ||
<div className="App"> | ||
<p>{t('description.part1')}</p> | ||
<p>{t('description.part2')}</p> | ||
</div> | ||
); | ||
} | ||
|
||
export default Comp2; |
14 changes: 14 additions & 0 deletions
14
example/react-typescript/simple-multi-namespaces/src/components/Comp3.tsx
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,14 @@ | ||
import { useTranslation } from "react-i18next"; | ||
|
||
function Comp2() { | ||
const {t} = useTranslation(['ns1', 'ns2']); | ||
|
||
return ( | ||
<div className="App"> | ||
<p>{t('ns1:description.part1')}</p> | ||
<p>{t('ns2:description.part2')}</p> | ||
</div> | ||
); | ||
} | ||
|
||
export default Comp2; |
20 changes: 20 additions & 0 deletions
20
example/react-typescript/simple-multi-namespaces/src/i18n/config.ts
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,20 @@ | ||
import i18next from 'i18next'; | ||
import { initReactI18next } from 'react-i18next'; | ||
import ns1 from './en/ns1.json'; | ||
import ns2 from './en/ns2.json'; | ||
|
||
export const defaultNS = 'ns1'; | ||
|
||
export const resources = { | ||
en: { | ||
ns1, | ||
ns2, | ||
} | ||
}; | ||
|
||
i18next.use(initReactI18next).init({ | ||
lng: 'en', // if you're using a language detector, do not define the lng option | ||
debug: true, | ||
resources, | ||
defaultNS, | ||
}); |
7 changes: 7 additions & 0 deletions
7
example/react-typescript/simple-multi-namespaces/src/i18n/en/ns1.json
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,7 @@ | ||
{ | ||
"title": "Welcome to react using react-i18next fully type-safe", | ||
"description": { | ||
"part1": "This is a simple example.", | ||
"part2": "😉" | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...script4.1/namespaces/src/i18n/en/ns2.json → ...ple-multi-namespaces/src/i18n/en/ns2.json
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"description": { | ||
"part1": "In order to infer the appropriate type for t function, you should use type augmentation to override the Resources type.", | ||
"part2": "Check out the @types/react-i18next to see an example." | ||
"part2": "Check out the @types/i18next to see an example." | ||
} | ||
} |
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
example/react-typescript/simple-multi-namespaces/src/index.tsx
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,13 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import './index.css'; | ||
import App from './App'; | ||
|
||
const root = ReactDOM.createRoot( | ||
document.getElementById('root') as HTMLElement | ||
); | ||
root.render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode> | ||
); |
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 |
---|---|---|
|
@@ -21,7 +21,6 @@ | |
"jsx": "react-jsx" | ||
}, | ||
"include": [ | ||
"src", | ||
"@types" | ||
"src" | ||
] | ||
} |
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 |
---|---|---|
|
@@ -22,4 +22,4 @@ npm-debug.log* | |
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
.eslintcache | ||
package-lock.json |
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
31 changes: 13 additions & 18 deletions
31
...-typescript4.1/no-namespaces/package.json → example/react-typescript/simple/package.json
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
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
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,7 @@ | ||
import { resources } from '../i18n/config'; | ||
|
||
declare module 'i18next' { | ||
interface CustomTypeOptions { | ||
resources: typeof resources['en']; | ||
} | ||
} |
File renamed without changes.
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,16 @@ | ||
import './i18n/config'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
function App() { | ||
const {t} = useTranslation(); | ||
|
||
return ( | ||
<div className="App"> | ||
<p>{t('title')}</p> | ||
<p>{t('description.part1')}</p> | ||
<p>{t('description.part2')}</p> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
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,15 @@ | ||
import i18next from 'i18next'; | ||
import { initReactI18next } from 'react-i18next'; | ||
import translation from './en/translation.json'; | ||
|
||
export const resources = { | ||
en: { | ||
translation, | ||
} | ||
}; | ||
|
||
i18next.use(initReactI18next).init({ | ||
lng: 'en', // if you're using a language detector, do not define the lng option | ||
debug: true, | ||
resources, | ||
}); |
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,7 @@ | ||
{ | ||
"title": "Welcome to react using react-i18next fully type-safe", | ||
"description": { | ||
"part1": "This is a simple example.", | ||
"part2": "😉" | ||
} | ||
} |
File renamed without changes.
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,13 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import './index.css'; | ||
import App from './App'; | ||
|
||
const root = ReactDOM.createRoot( | ||
document.getElementById('root') as HTMLElement | ||
); | ||
root.render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode> | ||
); |
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 |
---|---|---|
|
@@ -21,7 +21,6 @@ | |
"jsx": "react-jsx" | ||
}, | ||
"include": [ | ||
"src", | ||
"@types" | ||
"src" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
example/react-typescript4.1/namespaces/@types/react-i18next/index.d.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.