-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2295 from opral/next-adapter-improve-api
Next Adapter API Improvements
- Loading branch information
Showing
34 changed files
with
991 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@inlang/paraglide-js-adapter-next": patch | ||
--- | ||
|
||
fix: `middleware` no longer sets `Link` header on excluded pages |
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,8 @@ | ||
--- | ||
"@inlang/paraglide-js-adapter-next": patch | ||
--- | ||
|
||
Simplify API of the `<ParaglideJS>` component used in the pages router. | ||
You no longer need to pass the `runtime` and `router.locale` as props to the `<ParaglideJS>` component. Instead, you can just use the component without any props. It will automatically use the runtime and language tag from the context. | ||
|
||
This change was enabled by the last-minute plugin changes that made it valuale to use in the pages router. |
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,5 @@ | ||
--- | ||
"@inlang/paraglide-js-adapter-next": minor | ||
--- | ||
|
||
feat: Support translated Pathnames |
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
9 changes: 9 additions & 0 deletions
9
inlang/source-code/paraglide/paraglide-js-adapter-next/examples/app/src/lib/i18n.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 |
---|---|---|
@@ -1,7 +1,16 @@ | ||
import { AvailableLanguageTag } from "@/paraglide/runtime" | ||
import { createI18n } from "@inlang/paraglide-js-adapter-next" | ||
import * as m from "@/paraglide/messages" | ||
|
||
export const { Link, middleware, useRouter, usePathname, redirect, permanentRedirect } = | ||
createI18n<AvailableLanguageTag>({ | ||
exclude: ["/not-translated"], | ||
pathnames: { | ||
"/about": m.about_path, | ||
"/form": { | ||
en: "/form", | ||
de: "/formular", | ||
"de-CH": "/formular", | ||
}, | ||
}, | ||
}) |
5 changes: 2 additions & 3 deletions
5
inlang/source-code/paraglide/paraglide-js-adapter-next/examples/pages/src/pages/_app.tsx
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
22 changes: 0 additions & 22 deletions
22
inlang/source-code/paraglide/paraglide-js-adapter-next/src/app/config.d.ts
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
inlang/source-code/paraglide/paraglide-js-adapter-next/src/app/config.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,52 @@ | ||
import type { ExcludeConfig } from "./exclude" | ||
import { UserPathTranslations } from "./pathnames/types" | ||
|
||
export type I18nOptions<T extends string> = { | ||
/** | ||
* A list of patterns that should not be localized. | ||
* | ||
* @example | ||
* ```ts | ||
* exclude: [/^\/api\//] // Exclude `/api/*` from localization | ||
* ``` | ||
* | ||
* @default [] | ||
*/ | ||
exclude?: ExcludeConfig | ||
|
||
/** | ||
* The translations for pathnames. | ||
* They should **not** include the base path or the language tag. | ||
* | ||
* You can include parameters in the pathnames by using square brackets. | ||
* If you are using a parameter, you must include it in all translations. | ||
* | ||
* @example | ||
* ```ts | ||
* pathnames: { | ||
* "/about": { | ||
* de: "/ueber-uns", | ||
* en: "/about", | ||
* fr: "/a-propos", | ||
* }, | ||
* "/users/[slug]": { | ||
* en: "/users/[slug]", | ||
* // parameters don't have to be their own path-segment | ||
* de: "/benutzer-[slug]", | ||
* // parameters don't have to be in the same position | ||
* fr: "/[slug]/utilisateurs", | ||
* }, | ||
* //you can also use messages for pathnames (pass as reference) | ||
* "/admin": m.admin_path | ||
* } | ||
* ``` | ||
*/ | ||
pathnames?: UserPathTranslations<T> | ||
|
||
/** | ||
* The default language to use when no language is set. | ||
* | ||
* @default sourceLanguageTag | ||
*/ | ||
defaultLanguage?: T | ||
} |
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
Oops, something went wrong.