Skip to content

Commit

Permalink
Release 1.0.6 (#583)
Browse files Browse the repository at this point in the history
* replace quotes only for the special $' pattern specific to .replace() (#529)

* replace quotes only for the special $' pattern specific to .replace() instead of replacing quoutes everywhere

* use .replace() callback to avoid parsing special string patterns

* write tests to verify that templateWithHoc and templateWithLoader correctly replaces special string cases. Update snapshots

* Update package version

* fix(transCore): when no suffix don't match spaces (#534)

* Update package version

* _one works (#541)

* Update package version

* Update README.md (#552)

* Update package version

* Update dependencies (#554)

* Update dependencies

* Update example deps

* Update Trans text after change lang (#566)

* Ignore api.(ts|js...) file (#567)

* Add useMemo to useTranslation (#574)

* Update deps (#582)

* Update version of package.json

Co-authored-by: AndrewB <blauyedz@zoho.eu>
Co-authored-by: slevy85 <stephane.levy85@gmail.com>
Co-authored-by: Justin <jyork@genward.com>
  • Loading branch information
4 people authored Apr 17, 2021
1 parent a6b6550 commit 016de4b
Show file tree
Hide file tree
Showing 9 changed files with 907 additions and 354 deletions.
2 changes: 1 addition & 1 deletion examples/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "next build"
},
"dependencies": {
"next": "10.0.9",
"next": "10.1.3",
"next-translate": "link:../../",
"react": "link:../../node_modules/react",
"react-dom": "link:../../node_modules/react-dom"
Expand Down
12 changes: 6 additions & 6 deletions examples/complex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
},
"dependencies": {
"@mdx-js/loader": "1.6.22",
"@next/mdx": "10.0.9",
"next": "10.0.9",
"@next/mdx": "10.1.3",
"next": "10.1.3",
"next-translate": "link:../../",
"react": "link:../../node_modules/react",
"react-dom": "link:../../node_modules/react-dom"
},
"devDependencies": {
"@next/bundle-analyzer": "10.0.6",
"@types/node": "14.14.22",
"@types/react": "17.0.0",
"typescript": "4.1.3"
"@next/bundle-analyzer": "10.1.3",
"@types/node": "14.14.41",
"@types/react": "17.0.3",
"typescript": "4.2.4"
},
"resolutions": {
"webpack": "5.11.1"
Expand Down
2 changes: 1 addition & 1 deletion examples/without-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "next build"
},
"dependencies": {
"next": "10.0.9",
"next": "10.1.3",
"next-translate": "link:../../",
"react": "link:../../node_modules/react",
"react-dom": "link:../../node_modules/react-dom"
Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-translate",
"version": "1.0.5",
"version": "1.0.6",
"description": "Tiny and powerful i18n tools (Next plugin + API) to translate your Next.js pages.",
"license": "MIT",
"keywords": [
Expand Down Expand Up @@ -66,29 +66,29 @@
"next-translate": "./cli/builder.js"
},
"devDependencies": {
"@babel/cli": "7.13.10",
"@babel/core": "7.13.10",
"@babel/preset-env": "7.13.12",
"@babel/cli": "7.13.14",
"@babel/core": "7.13.15",
"@babel/preset-env": "7.13.15",
"@babel/preset-typescript": "7.13.0",
"@testing-library/react": "11.2.5",
"@types/node": "14.14.35",
"@testing-library/react": "11.2.6",
"@types/node": "14.14.41",
"@types/react": "17.0.3",
"@types/react-dom": "17.0.2",
"@types/webpack": "4.41.26",
"@types/react-dom": "17.0.3",
"@types/webpack": "5.28.0",
"babel-jest": "26.6.3",
"babel-plugin-transform-es2015-modules-commonjs": "6.26.2",
"babel-preset-minify": "0.5.1",
"cross-env": "7.0.3",
"express": "4.17.1",
"husky": "5.2.0",
"husky": "6.0.0",
"jest": "26.6.3",
"next": "10.0.9",
"next": "10.1.3",
"prettier": "2.2.1",
"pretty-quick": "3.1.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"supertest": "6.1.3",
"typescript": "4.2.3"
"typescript": "4.2.4"
},
"peerDependencies": {
"next": ">= 10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/I18nProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { createContext, useContext } from 'react'
import React, { createContext, useContext, useMemo } from 'react'
import { useRouter } from 'next/router'
import I18nContext from './_context'
import transCore from './transCore'
Expand Down
4 changes: 2 additions & 2 deletions src/Trans.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function Trans({
components,
fallback,
}: TransProps): any {
const { t } = useTranslation()
const { t, lang } = useTranslation()

/**
* Memorize the transformation
Expand All @@ -80,7 +80,7 @@ export default function Trans({
if (!components || components.length === 0) return text

return formatElements(text, components)
}, [i18nKey, values, components]) as string
}, [i18nKey, values, components, lang]) as string

return result
}
1 change: 1 addition & 0 deletions src/plugin/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function hasExportName(data: string, name: string) {
export function isPageToIgnore(page: string) {
return Boolean(
page.startsWith('/api/') ||
page.startsWith('/api.') ||
page.startsWith('/_document.') ||
page.match(specFileOrFolderRgx)
)
Expand Down
7 changes: 5 additions & 2 deletions src/useTranslation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext } from 'react'
import { useContext, useMemo } from 'react'
import { I18n } from '.'
import wrapTWithDefaultNs from './wrapTWithDefaultNs'
import I18nContext from './_context'
Expand All @@ -7,6 +7,9 @@ export default function useTranslation(defaultNs?: string): I18n {
const ctx = useContext(I18nContext)
return {
...ctx,
t: wrapTWithDefaultNs(ctx.t, defaultNs),
t: useMemo(() => wrapTWithDefaultNs(ctx.t, defaultNs), [
ctx.lang,
defaultNs,
]),
}
}
Loading

0 comments on commit 016de4b

Please sign in to comment.