Skip to content

Commit

Permalink
Merge pull request #784 from vinissimus/canary
Browse files Browse the repository at this point in the history
1.3.4
  • Loading branch information
aralroca authored Feb 14, 2022
2 parents bbaa3bf + cff0bd9 commit 7531ff2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
16 changes: 12 additions & 4 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@
]
},
{

"login": "testerez",
"name": "Tom Esterez",
"avatar_url": "https://avatars.githubusercontent.com/u/815236?v=4",
Expand All @@ -288,15 +287,15 @@
]
},
{
"login": "dndhm",
"login": "dndhm",
"name": "Dan Needham",
"avatar_url": "https://avatars.githubusercontent.com/u/1122983?v=4",
"profile": "http://www.dan-needham.com",
"contributions": [
"code",
"test",
"doc"
]
]
},
{
"login": "bmvantunes",
Expand All @@ -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",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://github.com/testerez"><img src="https://avatars.githubusercontent.com/u/815236?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tom Esterez</b></sub></a><br /><a href="https://github.com/vinissimus/next-translate/commits?author=testerez" title="Code">💻</a></td>
<td align="center"><a href="http://www.dan-needham.com"><img src="https://avatars.githubusercontent.com/u/1122983?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dan Needham</b></sub></a><br /><a href="https://github.com/vinissimus/next-translate/commits?author=dndhm" title="Code">💻</a> <a href="https://github.com/vinissimus/next-translate/commits?author=dndhm" title="Tests">⚠️</a> <a href="https://github.com/vinissimus/next-translate/commits?author=dndhm" title="Documentation">📖</a></td>
<td align="center"><a href="https://www.youtube.com/BrunoAntunesPT"><img src="https://avatars.githubusercontent.com/u/9042965?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bruno Antunes</b></sub></a><br /><a href="https://github.com/vinissimus/next-translate/commits?author=bmvantunes" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/kaan-atakan"><img src="https://avatars.githubusercontent.com/u/56063979?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kaan Atakan</b></sub></a><br /><a href="https://github.com/vinissimus/next-translate/commits?author=kaan-atakan" title="Code">💻</a></td>
</tr>
</table>
Expand Down
22 changes: 22 additions & 0 deletions __tests__/useTranslation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<I18nProvider
lang="en"
namespaces={{ common: { key: '{{somethingElse}}' } }}
>
<Inner />
</I18nProvider>
)
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'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion src/transCore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down

0 comments on commit 7531ff2

Please sign in to comment.