-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: simplify next-js integration (#3391)
- Loading branch information
Showing
85 changed files
with
1,562 additions
and
409 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
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 |
---|---|---|
|
@@ -18,6 +18,7 @@ jobs: | |
'next', | ||
'vue', | ||
'next-app', | ||
'next-app-intl', | ||
'svelte', | ||
'ngx', | ||
'react-i18next', | ||
|
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,40 @@ | ||
import { exampleAppTest } from '../../common/exampleAppTest'; | ||
import { translationMethodsTest } from '../../common/translationMethodsTest'; | ||
import { exampleAppDevTest } from '../../common/exampleAppDevTest'; | ||
|
||
context( | ||
'Next with app router (with next-intl) in dev mode', | ||
{ retries: 5 }, | ||
() => { | ||
const url = 'http://localhost:8125'; | ||
const translationMethods = url + '/en/translation-methods'; | ||
exampleAppTest(url); | ||
translationMethodsTest(translationMethods, { | ||
en: [ | ||
{ text: 'This is a key', count: 2 }, | ||
{ text: 'This is key with params value value2', count: 6 }, | ||
{ | ||
text: 'This is a key with tags bold value', | ||
count: 2, | ||
testId: 'translationWithTags', | ||
}, | ||
{ text: 'Translation in translation', count: 2 }, | ||
], | ||
de: [ | ||
{ text: 'Dies ist ein Schlüssel', count: 2 }, | ||
{ | ||
text: 'Dies ist ein Schlüssel mit den Parametern value value2', | ||
count: 6, | ||
}, | ||
{ | ||
text: 'Dies ist ein Schlüssel mit den Tags bold value', | ||
count: 2, | ||
testId: 'translationWithTags', | ||
}, | ||
{ text: 'Translation in translation', count: 2 }, | ||
], | ||
}); | ||
|
||
exampleAppDevTest(url, { noLoading: true }); | ||
} | ||
); |
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,33 @@ | ||
import { exampleAppTest } from '../../common/exampleAppTest'; | ||
import { translationMethodsTest } from '../../common/translationMethodsTest'; | ||
|
||
context('Next with app router (with next-intl) in prod mode', () => { | ||
const url = 'http://localhost:8127'; | ||
const translationMethods = url + '/en/translation-methods'; | ||
exampleAppTest(url); | ||
translationMethodsTest(translationMethods, { | ||
en: [ | ||
{ text: 'This is a key', count: 2 }, | ||
{ text: 'This is key with params value value2', count: 6 }, | ||
{ | ||
text: 'This is a key with tags bold value', | ||
count: 2, | ||
testId: 'translationWithTags', | ||
}, | ||
{ text: 'Translation in translation', count: 2 }, | ||
], | ||
de: [ | ||
{ text: 'Dies ist ein Schlüssel', count: 2 }, | ||
{ | ||
text: 'Dies ist ein Schlüssel mit den Parametern value value2', | ||
count: 6, | ||
}, | ||
{ | ||
text: 'Dies ist ein Schlüssel mit den Tags bold value', | ||
count: 2, | ||
testId: 'translationWithTags', | ||
}, | ||
{ text: 'Translation in translation', count: 2 }, | ||
], | ||
}); | ||
}); |
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
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
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
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
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
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
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
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
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
10 changes: 10 additions & 0 deletions
10
packages/web/src/package/tools/detectLanguageFromHeaders.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,10 @@ | ||
import { detectLanguage } from '../LanguageDetector'; | ||
import { getHeaderLanguages } from './getHeaderLanguages'; | ||
|
||
export const detectLanguageFromHeaders = ( | ||
headers: Headers, | ||
availableLanguages: string[] | ||
) => { | ||
const languages = getHeaderLanguages(headers); | ||
return languages[0] && detectLanguage(languages[0], availableLanguages); | ||
}; |
Oops, something went wrong.