Skip to content

Commit 6d5fea9

Browse files
committed
docs: fix lang for syntax highlighting
1 parent 558f7d9 commit 6d5fea9

5 files changed

Lines changed: 73 additions & 83 deletions

File tree

docs/content/docs/01.getting-started/02.usage.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ Nuxt I18n has a (configurable) folder structure from which the locale files are
5050

5151
With this configuration we can add a basic language switcher and translate our first message using:
5252

53-
<!-- prettier-ignore -->
5453
```vue [pages/index.vue]
5554
<script setup>
5655
const { locales, setLocale } = useI18n()
@@ -75,7 +74,6 @@ You now have a basic setup to get started with fully localizing your Nuxt Applic
7574
Some composable functions such as `useI18n` are [auto-imported by Nuxt](https://nuxt.com/docs/guide/concepts/auto-imports#auto-imports).
7675
If you have disabled `autoImports` you will need to import these explicitly from `#imports` as follows:
7776

78-
<!-- prettier-ignore -->
7977
```vue
8078
<script setup>
8179
import { useI18n, useLocalePath } from '#imports'
@@ -100,7 +98,6 @@ This function accepts two parameters:
10098

10199
::code-group
102100

103-
<!-- prettier-ignore -->
104101
```vue [page.vue (global function)]
105102
<template>
106103
<NuxtLink :to="$localePath('index')">{{ $t('home') }}</NuxtLink>
@@ -112,7 +109,6 @@ This function accepts two parameters:
112109
</template>
113110
```
114111

115-
<!-- prettier-ignore -->
116112
```vue [page.vue (composable)]
117113
<script setup>
118114
const localePath = useLocalePath()
@@ -140,15 +136,13 @@ The `$switchLocalePath` function returns the localized version of the route to t
140136

141137
::code-group
142138

143-
<!-- prettier-ignore -->
144139
```vue [page.vue (global function)]
145140
<template>
146141
<NuxtLink :to="$switchLocalePath('en')">English</NuxtLink>
147142
<NuxtLink :to="$switchLocalePath('nl')">Nederlands</NuxtLink>
148143
</template>
149144
```
150145

151-
<!-- prettier-ignore -->
152146
```vue [page.vue (composable)]
153147
<script setup>
154148
const switchLocalePath = useSwitchLocalePath()
@@ -170,7 +164,6 @@ You can localize advanced URL paths using `useLocaleRoute`. This is useful if yo
170164

171165
It works like `useLocalePath` but returns a route resolved by Vue Router rather than a full route path. This can be useful as the path returned from `useLocalePath` may not carry all information from the provided input (for example, route params that the page doesn't specify).
172166

173-
<!-- prettier-ignore -->
174167
```vue
175168
<script setup>
176169
const localeRoute = useLocaleRoute()

docs/content/docs/02.guide/03.custom-paths.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ You have some routes with the following `pages` directory:
7979
::callout{icon="i-heroicons-light-bulb"}
8080
Nested/child routes rely on there being a page component with the same name as the folder that renders the child routes.
8181
For more details, see [Nested Routes](https://nuxt.com/docs/guide/directory-structure/pages#nested-routes).
82-
::
82+
::
8383

8484
You would need to set up your `pages` property as follows:
8585

8686
```ts [nuxt.config.ts]
8787
export default defineNuxtConfig({
88-
i18n: {
88+
i18n: {
8989
customRoutes: 'config',
9090
pages: {
9191
parent: {
@@ -158,7 +158,6 @@ If a custom path is missing for one of the locales, the `defaultLocale` custom p
158158

159159
Say you have some dynamic routes like:
160160

161-
162161
```bash [Directory structure]
163162
-| pages/
164163
---| blog/
@@ -194,36 +193,35 @@ Path parameters parsing has been changed to match that of [Nuxt 3](https://nuxt.
194193

195194
You can use the `defineI18nRoute()`{lang="ts"} compiler macro to set custom paths for each page component.
196195

197-
```html {}[pages/about.vue]
196+
```vue {}[pages/about.vue]
198197
<script setup>
199-
defineI18nRoute({
200-
paths: {
201-
en: '/about-us', // -> accessible at /about-us (no prefix since it's the default locale)
202-
fr: '/a-propos', // -> accessible at /fr/a-propos
203-
es: '/sobre' // -> accessible at /es/sobre
204-
}
205-
})
198+
defineI18nRoute({
199+
paths: {
200+
en: '/about-us', // -> accessible at /about-us (no prefix since it's the default locale)
201+
fr: '/a-propos', // -> accessible at /fr/a-propos
202+
es: '/sobre' // -> accessible at /es/sobre
203+
}
204+
})
206205
</script>
207206
```
208207

209208
To configure a custom path for a dynamic route, you need to use it in double square brackets in the paths similarly to how you would do it in [Nuxt Dynamic Routes](https://nuxt.com/docs/guide/directory-structure/pages#dynamic-routes):
210209

211-
```html {}[pages/articles/[name\\].vue]
210+
```vue {}[pages/articles/[name].vue]
212211
<script setup>
213-
defineI18nRoute({
214-
paths: {
215-
en: '/articles/[name]',
216-
es: '/artículo/[name]'
217-
}
218-
})
212+
defineI18nRoute({
213+
paths: {
214+
en: '/articles/[name]',
215+
es: '/artículo/[name]'
216+
}
217+
})
219218
</script>
220219
```
221220

222221
::callout{icon="i-heroicons-light-bulb"}
223222
`defineI18nRoute()`{lang="ts"} compiler macro is tree-shaken out at build time and is not included in the dist files.
224223
::
225224

226-
227225
## Dynamic route parameters
228226

229227
Dealing with dynamic route parameters requires a bit more work because you need to provide parameters translations to **Nuxt i18n module**. The composable `useSetI18nParams` can be used to set translations for route parameters, this is used to set SEO tags as well as changing the routes returned by `switchLocalePath`.
@@ -238,7 +236,7 @@ Components which have already been rendered do not update by changes introduced
238236
This is not the case for SEO tags, these are updated correctly during SSR regardless of when and where i18n parameters are set.
239237

240238
:br :br
241-
Check out the experimental [`switchLocalePathLinkSSR`](/docs/api/options#switchlocalepathlinkssr) feature, which combined with the [`<SwitchLocalePathLink>`{lang="html"}](/docs/components/switch-locale-path-link) component, correctly renders links during SSR regardless of where and when it is used.
239+
Check out the experimental [`switchLocalePathLinkSSR`](/docs/api/options#switchlocalepathlinkssr) feature, which combined with the [`<SwitchLocalePathLink>`{lang="html"}](/docs/components/switch-locale-path-link) component, correctly renders links during SSR regardless of where and when it is used.
242240
::
243241

244242
An example (replace `slug` with the applicable route parameter):
@@ -296,7 +294,7 @@ This experimental feature can be enabled as shown here:
296294
```typescript {}[nuxt.config.ts]
297295
export default defineNuxtConfig({
298296
experimental: {
299-
scanPageMeta: true,
297+
scanPageMeta: true
300298
}
301299
})
302300
```

docs/content/docs/02.guide/90.migrating.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ description: Follow this guide to upgrade from one major version to the other.
77

88
### Upgrade to Vue I18n v10
99

10-
Vue I18n has been upgraded from v9 to v10. Vue I18n v10 has no major feature additions, but there are some disruptive changes, such as dropping some features that were deprecated in v9 and integrating the API `$tc()`{lang="ts"} into `$t()`{lang="ts"}, which can be used in the Legacy API style
10+
Vue I18n has been upgraded from v9 to v10. Vue I18n v10 has no major feature additions, but there are some disruptive changes, such as dropping some features that were deprecated in v9 and integrating the API `$tc()`{lang="ts"} into `$t()`{lang="ts"}, which can be used in the Legacy API style
1111

1212
Check the documentation [here](https://vue-i18n.intlify.dev/guide/migration/breaking10.html#change-t-and-t-overloaded-signature-for-legacy-api-mode) for more information.
1313

14-
1514
### Drop `jit` option
1615

17-
JIT compilation is now the default in Vue I18n v10.
16+
JIT compilation is now the default in Vue I18n v10.
1817

1918
https://vue-i18n.intlify.dev/guide/migration/breaking10.html#default-enable-for-jit-compilation
2019

@@ -25,8 +24,9 @@ Accordingly, the `jit` option in Nuxt I18n v8 is no longer needed, so this optio
2524
We now use a default directory structure that is consistent with [directory structure changes in Nuxt 4](https://nuxt.com/docs/getting-started/upgrade#new-directory-structure).
2625

2726
What changed
28-
* `langDir` now defaults to `'locales'`{lang="ts"}.
29-
* All i18n files are resolved relative to `<rootDir>/i18n`, this can be configured with the `restructureDir` option.
27+
28+
- `langDir` now defaults to `'locales'`{lang="ts"}.
29+
- All i18n files are resolved relative to `<rootDir>/i18n`, this can be configured with the `restructureDir` option.
3030

3131
Here is an example of a project structure after this change:
3232

@@ -43,8 +43,9 @@ nuxt.config.ts
4343
```
4444

4545
Reasons for change
46-
1. Context - i18n files are used both server-side and client-side, using a dedicated `i18n/` folder in the root directory outside `app/` and `server/` makes more sense.
47-
2. Clean - less clutter/fragmentation of i18n files, and should make resolving and loading files easier for us.
46+
47+
1. Context - i18n files are used both server-side and client-side, using a dedicated `i18n/` folder in the root directory outside `app/` and `server/` makes more sense.
48+
2. Clean - less clutter/fragmentation of i18n files, and should make resolving and loading files easier for us.
4849

4950
To ease the migration to v9 you can disable this feature by setting `restructureDir: false`{lang="ts"}, this will be removed in v10.
5051

@@ -56,29 +57,29 @@ The `iso` property on a locale object has been renamed to `language` to be consi
5657

5758
Some properties have changed or swapped names to better fit their functionality, the runtime config properties configured by this module are mostly used for internal purposes and should not be relied upon but it's worth noting these changes.
5859

59-
| v8 | v9 | Notes |
60-
| --- | --- | --- |
61-
| `locales` | `domainLocales` | This also changes the environment variable key to `NUXT_PUBLIC_I18N_DOMAIN_LOCALES_{code}_DOMAIN`, see [`runtimeConfig`](/docs/api/runtime-config#domainLocales) |
62-
| `configLocales` | `locales` | |
60+
| v8 | v9 | Notes |
61+
| --------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
62+
| `locales` | `domainLocales` | This also changes the environment variable key to `NUXT_PUBLIC_I18N_DOMAIN_LOCALES_{code}_DOMAIN`, see [`runtimeConfig`](/docs/api/runtime-config#domainLocales) |
63+
| `configLocales` | `locales` | |
6364

6465
### SEO - `useLocaleHead()`{lang="ts"}
6566

6667
The options parameter for `useLocaleHead()`{lang="ts"} and `$localeHead()`{lang="ts"} has changed in shape, having less verbose property names, as well as enabling the options by default.
6768

6869
This table compares the option properties of `useLocaleHead()`{lang="ts"} and `$localeHead()`{lang="ts"} for v8 and v9:
6970

70-
| v8 | v9 | Notes |
71-
| --- | --- | --- |
72-
| `-` | `lang` | New property to configure the `lang` html attributes, default: `true` |
73-
| `addDirAttributes` | `dir` | Default changed: `false` -> `true` |
74-
| `addSeoAttributes` | `seo` | Default changed: `false` -> `true` |
75-
| `identifierAttribute` | `key` | |
71+
| v8 | v9 | Notes |
72+
| --------------------- | ------ | --------------------------------------------------------------------- |
73+
| `-` | `lang` | New property to configure the `lang` html attributes, default: `true` |
74+
| `addDirAttributes` | `dir` | Default changed: `false` -> `true` |
75+
| `addSeoAttributes` | `seo` | Default changed: `false` -> `true` |
76+
| `identifierAttribute` | `key` | |
7677

7778
We have added a `lang` property to the options parameter of `useLocaleHead()`{lang="ts"} and `$localeHead()`{lang="ts"}, originally this was not configurable on its own, see [`useLocaleHead()`{lang="ts"}](/docs/composables/use-locale-head) for details on its usage.
7879

7980
### Nuxt context functions
8081

81-
In v8 both the types and name of the injected context functions (such as `$localePath()`{lang="ts"}, `$switchLocalePath()`{lang="ts"} and [more](/docs/api/nuxt)) did not work as intended. You may have found that these functions worked when using them without prefix (`$`) even when not assigning these functions from a composable.
82+
In v8 both the types and name of the injected context functions (such as `$localePath()`{lang="ts"}, `$switchLocalePath()`{lang="ts"} and [more](/docs/api/nuxt)) did not work as intended. You may have found that these functions worked when using them without prefix (`$`) even when not assigning these functions from a composable.
8283

8384
The types and names have been fixed in v9, if you have been using the unprefixed functions globally (without composable) in your project you will have to prefix these functions as they were originally intended.
8485

@@ -96,7 +97,7 @@ Setting dynamic route parameters by setting the `nuxtI18n` property with `define
9697

9798
The composable usage is similar to that of the deprecated implementation, see the migration example below:
9899

99-
```html
100+
```vue
100101
<script>
101102
definePageMeta({
102103
nuxtI18n: {
@@ -112,12 +113,12 @@ definePageMeta({
112113

113114
Should be changed to:
114115

115-
```html
116+
```vue
116117
<script>
117-
const setI18nParams = useSetI18nParams();
118+
const setI18nParams = useSetI18nParams()
118119
setI18nParams({
119-
en: { id: 'my-post' },
120-
fr: { id: 'mon-article' }
120+
en: { id: 'my-post' },
121+
fr: { id: 'mon-article' }
121122
})
122123
</script>
123124
<template>
@@ -127,7 +128,6 @@ setI18nParams({
127128

128129
Check out the [Lang Switcher](/docs/guide/lang-switcher#dynamic-route-parameters) guide for more details.
129130

130-
131131
## Upgrading from `nuxtjs/i18n` v7.x to v8.x
132132

133133
### Deprecated `vueI18n` option to not accept `createI18n` options

docs/content/docs/04.api/00.options.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ The Vue I18n `messages` option should be returned **by the plain object**.
6565
That will be pre-compiled in the nuxt i18n module via vue-i18n message-compiler as an executable message in the vue-i18n runtime.
6666
::
6767

68-
69-
7068
## baseUrl
7169

7270
- type: `string | Function`{lang="ts-type"}
@@ -150,6 +148,7 @@ When using an object form, the properties can be:
150148
- Set `domainDefault` to `true` for each locale that should act as a default locale for the particular domain. This property is required when using [`differentDomains`](/docs/api/options#differentdomains) while one or more of the domains having multiple locales
151149

152150
### `...`
151+
153152
- any custom property set on the object will be exposed at runtime. This can be used, for example, to define the language name for the purpose of using it in a language selector on the page.
154153

155154
You can access all the properties of the current locale through the `localeProperties` property. When using an array of codes, it will only include the `code` property.
@@ -530,7 +529,7 @@ Configure the `i18n` custom blocks of SFC.
530529

531530
Supported properties:
532531

533-
### `defaultSFCLang`
532+
### `defaultSFCLang`
534533

535534
- type: `'json' | 'json5' | 'yaml' | 'yml'`{lang="ts-type"}
536535
- default: `'json'`{lang="ts-type"}
@@ -540,7 +539,7 @@ On inlined `i18n` custom blocks that have specified the `lang` attribute, the `d
540539

541540
For example, with `defaultSFCLang: "yaml"`{lang="ts"} or `defaultSFCLang: "yml"`{lang="ts"}, this custom block:
542541

543-
```html
542+
```vue
544543
<i18n lang="yaml">
545544
en:
546545
hello: Hello
@@ -551,7 +550,7 @@ es:
551550

552551
Would be equivalent to this:
553552

554-
```html
553+
```vue
555554
<i18n>
556555
en:
557556
hello: Hello
@@ -572,7 +571,7 @@ beware enabling `globalSFCScope: true`{lang="ts"}, all `i18n` custom blocks in a
572571

573572
For example, with `globalSFCScope: true`{lang="ts"}, this custom block:
574573

575-
```html
574+
```vue
576575
<i18n lang="yaml" global>
577576
en:
578577
hello: Hello
@@ -583,7 +582,7 @@ es:
583582

584583
Would be equivalent to this:
585584

586-
```html
585+
```vue
587586
<i18n lang="yaml">
588587
en:
589588
hello: Hello
@@ -594,7 +593,7 @@ es:
594593

595594
This combines with `defaultSFCLang`, with `defaultSFCLang: "yaml"`{lang="ts"} the following would be equivalent to the previous examples:
596595

597-
```html
596+
```vue
598597
<i18n>
599598
en:
600599
hello: Hello
@@ -608,8 +607,9 @@ es:
608607
- type: `'composition' | 'legacy'`{lang="ts-type"}
609608
- default: `'composition'`{lang="ts-type"}
610609

611-
Enforces the type definition of the API style to be used.
612-
- Set to `'composition'`{lang="ts-type"}, Composition API types provided by Vue I18n and `@nuxtjs/i18n` are supported,
610+
Enforces the type definition of the API style to be used.
611+
612+
- Set to `'composition'`{lang="ts-type"}, Composition API types provided by Vue I18n and `@nuxtjs/i18n` are supported,
613613
- Set to `'legacy'`{lang="ts-type"}, Options API types are supported.
614614

615615
::callout{icon="i-heroicons-exclamation-triangle" color="warning"}

0 commit comments

Comments
 (0)