Skip to content

Commit

Permalink
Merge pull request #35 from JCQuintas/chore/add-i18next-21-docs
Browse files Browse the repository at this point in the history
docs: Add i18next 21 docs
chore: update packages
  • Loading branch information
JCQuintas authored Oct 18, 2021
2 parents 89c7b0a + 392ef08 commit 1805f07
Show file tree
Hide file tree
Showing 12 changed files with 836 additions and 862 deletions.
2 changes: 1 addition & 1 deletion data/example-template/ni18n.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import type { Ni18nOptions } from 'ni18n'

export const ni18nConfig: Ni18nOptions = {
supportedLngs: ['en', 'es', 'pt'],
ns: ['alternate', 'home', 'translation', 'client'],
ns: ['translation', 'alternate', 'home', 'client'],
}
4 changes: 3 additions & 1 deletion docs/usage/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ import type { Ni18nOptions } from 'ni18n'

export const ni18nConfig: Ni18nOptions = {
supportedLngs: ['en', 'es'],
ns: ['your-namespaces'],
ns: ['your-default-namespace', 'your-other-namespaces...'],
}
```

> **i18next >= 21** The first item in the `ns` array will be set as your `default` and allow you to call `useTranslation()` without any parameters to use it. If you want to manually select the default, then you can set the `defaultNS` property.
> Note: The `name` and `location` of the file don't really matter, you can call it anything and put it anywhere you want.
## 3. Translation Files
Expand Down
2 changes: 1 addition & 1 deletion examples/cached-translations/ni18n.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const isBrowser = typeof window !== 'undefined'

export const ni18nConfig = {
supportedLngs: ['en', 'es', 'pt'],
ns: ['alternate', 'home', 'translation', 'client'],
ns: ['translation', 'alternate', 'home', 'client'],
use: isBrowser ? [ChainedBackend] : undefined,
backend: isBrowser
? {
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-backend/ni18n.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import HttpBackend from 'i18next-http-backend'

export const ni18nConfig = {
supportedLngs: ['en', 'es', 'pt'],
ns: ['alternate', 'home', 'translation', 'client'],
ns: ['translation', 'alternate', 'home', 'client'],
backend: {
loadPath: 'http://localhost:7777/{{lng}}/{{ns}}',
},
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-language-selection/ni18n.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const ni18nConfig = {
*/
fallbackLng: supportedLngs,
supportedLngs,
ns: ['alternate', 'home', 'translation', 'client'],
ns: ['translation', 'alternate', 'home', 'client'],
react: {
useSuspense: false,
},
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-location/ni18n.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const localePath = '/custom/{{lng}}.{{ns}}.json'

export const ni18nConfig = {
supportedLngs: ['en', 'es', 'pt'],
ns: ['alternate', 'home', 'translation', 'client'],
ns: ['translation', 'alternate', 'home', 'client'],
backend: {
loadPath:
typeof window === 'undefined' ? `./public/${localePath}` : localePath,
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/ni18n.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const ni18nConfig = {
supportedLngs: ['en', 'es', 'pt'],
ns: ['alternate', 'home', 'translation', 'client'],
ns: ['translation', 'alternate', 'home', 'client'],
}
3 changes: 3 additions & 0 deletions examples/typescript/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
2 changes: 1 addition & 1 deletion examples/typescript/ni18n.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import type { Ni18nOptions } from 'ni18n'

export const ni18nConfig: Ni18nOptions = {
supportedLngs: ['en', 'es', 'pt'],
ns: ['alternate', 'home', 'translation', 'client'],
ns: ['translation', 'alternate', 'home', 'client'],
}
7 changes: 6 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/**/index.{ts,tsx}'],
modulePathIgnorePatterns: ['<rootDir>/dist', '<rootDir>/e2e'],
modulePathIgnorePatterns: [
'<rootDir>/dist',
'<rootDir>/e2e',
'<rootDir>/data',
'<rootDir>/examples',
],
moduleNameMapper: {
'use-backend': '<rootDir>/src/use-backend/browser.ts',
},
Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,44 +40,44 @@
"i18next-http-backend": "^1.3.1"
},
"devDependencies": {
"@babel/core": "^7.15.5",
"@babel/core": "^7.15.8",
"@babel/preset-typescript": "^7.15.0",
"@oclif/command": "^1.8.0",
"@playwright/test": "^1.15.0",
"@playwright/test": "^1.15.2",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.1.0",
"@testing-library/react": "^12.1.2",
"@testing-library/react-hooks": "^7.0.2",
"@types/hoist-non-react-statics": "^3.3.1",
"@types/i18next-fs-backend": "^1.1.2",
"@types/jest": "^27.0.2",
"@types/node": "^16.9.6",
"@types/react": "^17.0.24",
"@types/node": "^16.11.1",
"@types/react": "^17.0.30",
"@types/react-dom": "^17.0.9",
"@typescript-eslint/eslint-plugin": "^4.31.2",
"@typescript-eslint/parser": "^4.31.2",
"@typescript-eslint/eslint-plugin": "^5.1.0",
"@typescript-eslint/parser": "^5.1.0",
"chalk": "^4.1.2",
"copyfiles": "^2.4.1",
"deepmerge": "^4.2.2",
"enquirer": "^2.3.6",
"eslint": "^7.32.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^24.4.2",
"eslint-plugin-react": "^7.26.0",
"i18next": "^20.6.1",
"jest": "^27.2.1",
"lint-staged": "^11.1.2",
"listr2": "^3.12.1",
"eslint-plugin-jest": "^25.2.2",
"eslint-plugin-react": "^7.26.1",
"i18next": "^21.3.2",
"jest": "^27.3.0",
"lint-staged": "^11.2.3",
"listr2": "^3.12.2",
"next": "^11.1.2",
"nodemon": "^2.0.12",
"nodemon": "^2.0.13",
"prettier": "^2.4.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-i18next": "^11.12.0",
"rimraf": "^3.0.2",
"simple-git-hooks": "^2.6.1",
"ts-jest": "^27.0.5",
"ts-node": "^10.2.1",
"typescript": "^4.4.3"
"ts-jest": "^27.0.7",
"ts-node": "^10.3.0",
"typescript": "^4.4.4"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
Expand Down
Loading

0 comments on commit 1805f07

Please sign in to comment.