diff --git a/.all-contributorsrc b/.all-contributorsrc index c516abe5..10e74bc4 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -278,7 +278,6 @@ ] }, { - "login": "testerez", "name": "Tom Esterez", "avatar_url": "https://avatars.githubusercontent.com/u/815236?v=4", @@ -288,7 +287,7 @@ ] }, { - "login": "dndhm", + "login": "dndhm", "name": "Dan Needham", "avatar_url": "https://avatars.githubusercontent.com/u/1122983?v=4", "profile": "http://www.dan-needham.com", @@ -296,7 +295,7 @@ "code", "test", "doc" - ] + ] }, { "login": "bmvantunes", @@ -306,7 +305,16 @@ "contributions": [ "code" ] - } + }, + { + "login": "kaan-atakan", + "name": "Kaan Atakan", + "avatar_url": "https://avatars.githubusercontent.com/u/56063979?v=4", + "profile": "https://github.com/kaan-atakan", + "contributions": [ + "code" + ] + } ], "contributorsPerLine": 7, "projectName": "next-translate", diff --git a/README.md b/README.md index dd3a3b36..c5fa3a9e 100644 --- a/README.md +++ b/README.md @@ -959,6 +959,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Tom Esterez

💻
Dan Needham

💻 ⚠️ 📖
Bruno Antunes

💻 +
Kaan Atakan

💻 diff --git a/__tests__/useTranslation.test.js b/__tests__/useTranslation.test.js index ebb5f3df..4ad29e2d 100644 --- a/__tests__/useTranslation.test.js +++ b/__tests__/useTranslation.test.js @@ -44,6 +44,28 @@ describe('useTranslation', () => { expect(container.textContent).toBe(expected) }) + test('interpolation should not be lazy', () => { + const Inner = () => { + const { t } = useTranslation() + return t('common:key', { + something: 'something', + somethingElse: 'something else', + }) + } + + const expected = 'something else' + + const { container } = render( + + + + ) + expect(container.textContent).toBe(expected) + }) + test('should return the key as fallback using wrong the nested translations', () => { const i18nKey = 'ns:grandfather.parent' const expected = 'ns:grandfather.parent' diff --git a/package.json b/package.json index bd075151..b0449e2c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "next-translate", - "version": "1.3.3", + "version": "1.3.4", "description": "Tiny and powerful i18n tools (Next plugin + API) to translate your Next.js pages.", "license": "MIT", "keywords": [ diff --git a/src/transCore.tsx b/src/transCore.tsx index 426ccfa7..86528a63 100644 --- a/src/transCore.tsx +++ b/src/transCore.tsx @@ -183,7 +183,7 @@ function interpolation({ } = config.interpolation || {} const regexEnd = - suffix === '' ? '' : `\\s*,?\\s*([\\w-]+)?\\s*${escapeRegex(suffix)}` + suffix === '' ? '' : `(?:[\\s,]+([\\w-]*))?\\s*${escapeRegex(suffix)}` return Object.keys(query).reduce((all, varKey) => { const regex = new RegExp( `${escapeRegex(prefix)}\\s*${varKey}${regexEnd}`,