Skip to content

Commit

Permalink
feat: improve defineI18nRoute parameter type
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede committed Sep 27, 2024
1 parent 2bb26c9 commit 1214bd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions docs/content/docs/5.v9/4.api/3.compiler-macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ defineI18nRoute({
defineI18nRoute(route: I18nRoute | false) => void

interface I18nRoute {
paths?: Record<string, string>
locales?: string[]
paths?: Record<Locale, `/${string}`>
locales?: Locale[]
}
```

Expand All @@ -42,12 +42,12 @@ An object accepting the following i18n route settings:

- **`paths`**

- **Type**: `Record<Locale, string>`
- **Type**: `Record<Locale, `/${string}`>`

Customize page component routes per locale. You can specify static and dynamic paths for vue-router.

- **`locales`**

- **Type**: `string[]`
- **Type**: `Locale[]`

Some locales to which the page component should be localized.
3 changes: 1 addition & 2 deletions src/runtime/composables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ export function useBrowserLocale(): string | null {
const headers = useRequestHeaders(['accept-language'])
return (
findBrowserLocale(

normalizedLocales as LocaleObject[],

Check failure on line 404 in src/runtime/composables/index.ts

View workflow job for this annotation

GitHub Actions / Lint on Node.js 18

This assertion is unnecessary since it does not change the type of the expression
import.meta.client ? (navigator.languages as string[]) : parseAcceptLanguage(headers['accept-language'] || '')
) || null
Expand Down Expand Up @@ -468,7 +467,7 @@ export interface I18nRoute {
*
* @description You can specify static and dynamic paths for vue-router.
*/
paths?: Partial<Record<Locale, string>>
paths?: Partial<Record<Locale, `/${string}`>>
/**
* Some locales to which the page component should be localized.
*/
Expand Down

0 comments on commit 1214bd2

Please sign in to comment.