Skip to content

Commit

Permalink
refactor!: rename package to @nuxtjs/i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl committed Aug 3, 2021
1 parent 3b2ecfd commit b3ef21c
Show file tree
Hide file tree
Showing 22 changed files with 83 additions and 83 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ assignees: ''
---

### Version
nuxt-i18n: <!-- ex: 5.9.0 -->
@nuxtjs/i18n: <!-- ex: 1.0.0 -->
nuxt: <!-- ex: 2.0.0 -->

### Nuxt configuration
#### [mode](https://nuxtjs.org/guides/configuration-glossary/configuration-mode): <!--universal is the default, please insert X where appropriate -->
- [] universal
- [] spa

### Nuxt-i18n configuration
### @nuxtjs/i18n configuration
<!--
If relevant, please include the configuration you are using for this module.
For example:
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ contact_links:
- name: Nuxt Community Discord
url: https://discord.nuxtjs.org/
about: Consider asking questions about the module here.
- name: nuxt-i18n Documentation
- name: '@nuxtjs/i18n Documentation'
url: https://i18n.nuxtjs.org/
about: Check our documentation before reporting issues or questions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ assignees: ''
**IMPORTANT!**
Please make sure to look for an answer to your question in our documentation before asking a question here.
If relevant to your question, provide nuxt-i18n configuration.
If relevant to your question, provide @nuxtjs/i18n configuration.
If you have a general question regarding nuxt-i18n use Discord `modules` channel. Thanks!
If you have a general question regarding @nuxtjs/i18n use Discord `i18n` channel. Thanks!
Documentation: https://i18n.nuxtjs.org/
Nuxt Discord: https://discord.nuxtjs.org/
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<p align="center">
<img src="./docs/static/preview.png" alt="nuxt-i18n logo">
<img src="./docs/static/preview.png" alt="@nuxtjs/i18n logo">
</p>

[![](https://david-dm.org/nuxt-community/i18n-module/status.svg?style=flat-square)](https://david-dm.org/nuxt-community/i18n-module)
[![](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com)
[![](https://img.shields.io/codecov/c/github/nuxt-community/i18n-module.svg?style=flat-square)](https://codecov.io/gh/nuxt-community/i18n-module)
[![](https://snyk.io/test/github/nuxt-community/i18n-module/badge.svg?style=flat-square)](https://snyk.io/test/github/nuxt-community/i18n-module)
[![](https://img.shields.io/npm/v/nuxt-i18n/latest.svg?style=flat-square)](https://npmjs.com/package/nuxt-i18n)
[![](https://img.shields.io/npm/dt/nuxt-i18n.svg?style=flat-square)](https://npmjs.com/package/nuxt-i18n)
[![](https://img.shields.io/npm/v/%40nuxtjs-i18n/latest.svg?style=flat-square)](https://npmjs.com/package/%40nuxtjs-i18n)
[![](https://img.shields.io/npm/dt/%40nuxtjs-i18n.svg?style=flat-square)](https://npmjs.com/package/%40nuxtjs-i18n)

> i18n for your Nuxt project
Expand All @@ -28,20 +28,20 @@

## Setup
```sh
yarn add nuxt-i18n # yarn
npm i nuxt-i18n # npm
yarn add @nuxtjs/i18n # yarn
npm i @nuxtjs/i18n # npm
```

## Basic usage
Firstly, you need to add `nuxt-i18n` to your Nuxt config.
Firstly, you need to add `@nuxtjs/i18n` to your Nuxt config.

```javascript
// nuxt.config.js

{
modules: [
[
'nuxt-i18n',
'@nuxtjs/i18n',
{
locales: ['en', 'es'],
defaultLocale: 'en',
Expand All @@ -62,7 +62,7 @@ Firstly, you need to add `nuxt-i18n` to your Nuxt config.
}
```

Then you can start using `nuxt-i18n` in your Vue components!
Then you can start using `@nuxtjs/i18n` in your Vue components!

```html
<template>
Expand All @@ -86,7 +86,7 @@ Then you can start using `nuxt-i18n` in your Vue components!
</template>
```

If you would like to find out more about how to use `nuxt-i18n`, [check out the docs](https://i18n.nuxtjs.org/)!
If you would like to find out more about how to use `@nuxtjs/i18n`, [check out the docs](https://i18n.nuxtjs.org/)!

## Issues, questions & requests

Expand Down
4 changes: 2 additions & 2 deletions docs/content/en/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ category: Api

<alert type="info">

All [Vue I18n properties and methods](http://kazupon.github.io/vue-i18n/api/#vue-injected-methods) (like `$t`, `$i18n`, `v-t` directive and others) are also available even though they are not listed here. Below are only the ones that are added by `nuxt-i18n`.
All [Vue I18n properties and methods](http://kazupon.github.io/vue-i18n/api/#vue-injected-methods) (like `$t`, `$i18n`, `v-t` directive and others) are also available even though they are not listed here. Below are only the ones that are added by `@nuxtjs/i18n`.

</alert>

Expand Down Expand Up @@ -42,7 +42,7 @@ All [Vue I18n properties and methods](http://kazupon.github.io/vue-i18n/api/#vue
- route (type: [`Route`](https://github.com/vuejs/vue-router/blob/f40139c27a9736efcbda69ec136cb00d8e00fa97/types/router.d.ts#L135), default: current route)
- **Returns**: `string`

Returns base name of current (if argument not provided) or passed in `route`. Base name is name of the route without locale suffix and other metadata added by `nuxt-i18n`.
Returns base name of current (if argument not provided) or passed in `route`. Base name is name of the route without locale suffix and other metadata added by `@nuxtjs/i18n`.

### localeRoute()

Expand Down
10 changes: 5 additions & 5 deletions docs/content/en/basic-usage.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
title: Basic Usage
description: 'The fastest way to get started with **nuxt-i18n** is to define the supported `locales` list and to provide some translation messages to **vue-i18n** via the `vueI18n` option:'
description: 'The fastest way to get started with **@nuxtjs/i18n** is to define the supported `locales` list and to provide some translation messages to **vue-i18n** via the `vueI18n` option:'
position: 3
category: Getting started
---

The fastest way to get started with **nuxt-i18n** is to define the supported `locales` list and to provide some translation messages to **vue-i18n** via the `vueI18n` option:
The fastest way to get started with **@nuxtjs/i18n** is to define the supported `locales` list and to provide some translation messages to **vue-i18n** via the `vueI18n` option:

```js {}[nuxt.config.js]
{
modules: [
'nuxt-i18n'
'@nuxtjs/i18n'
],

i18n: {
Expand All @@ -34,13 +34,13 @@ The fastest way to get started with **nuxt-i18n** is to define the supported `lo
}
```

With this setup, **nuxt-i18n** generates localized URLs for all your pages, using the codes provided in the `locales` option as the prefix, except for the `defaultLocale` (read more on [routing](/routing)).
With this setup, **@nuxtjs/i18n** generates localized URLs for all your pages, using the codes provided in the `locales` option as the prefix, except for the `defaultLocale` (read more on [routing](/routing)).

The `vueI18n` option is passed as is to **vue-i18n**, refer to the [doc](https://kazupon.github.io/vue-i18n/) for available options.

## nuxt-link

When rendering internal links in your app using `<nuxt-link>`, you need to get proper URLs for the current locale. To do this, **nuxt-i18n** registers a global mixin that provides some helper functions:
When rendering internal links in your app using `<nuxt-link>`, you need to get proper URLs for the current locale. To do this, **@nuxtjs/i18n** registers a global mixin that provides some helper functions:

* `localePath` – Returns the localized URL for a given page. The first parameter can be either the path or name of the route or an object for more complex routes. A locale code can be passed as the second parameter to generate a link for a specific language:

Expand Down
18 changes: 9 additions & 9 deletions docs/content/en/browser-language-detection.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: Browser language detection
description: "By default, **nuxt-i18n** attempts to redirect users to their preferred language by detecting their browser's language. This is controlled by the `detectBrowserLanguage` option:"
description: "By default, **@nuxtjs/i18n** attempts to redirect users to their preferred language by detecting their browser's language. This is controlled by the `detectBrowserLanguage` option:"
position: 7
category: Guide
---

By default, **nuxt-i18n** attempts to redirect users to their preferred language by detecting their browser's language. This is controlled by the `detectBrowserLanguage` option:
By default, **@nuxtjs/i18n** attempts to redirect users to their preferred language by detecting their browser's language. This is controlled by the `detectBrowserLanguage` option:

```js {}[nuxt.config.js]
['nuxt-i18n', {
['@nuxtjs/i18n', {
// ...
detectBrowserLanguage: {
useCookie: true,
Expand All @@ -26,10 +26,10 @@ For better SEO, it's recommended to set `redirectOn` to `root` (which is the def

Browser language is detected either from `navigator` when running on client-side, or from the `accept-language` HTTP header. Configured `locales` (or locales `iso` and/or `code` when locales are specified in object form) are matched against locales reported by the browser (for example `en-US,en;q=0.9,no;q=0.8`). If there is no exact match for the full locale, the language code (letters before `-`) are matched against configured locales.

To prevent redirecting users every time they visit the app, **nuxt-i18n** sets a cookie after the first redirection. You can change the cookie's name by setting `detectBrowserLanguage.cookieKey` option to whatever you'd like, the default is _i18n_redirected_.
To prevent redirecting users every time they visit the app, **@nuxtjs/i18n** sets a cookie after the first redirection. You can change the cookie's name by setting `detectBrowserLanguage.cookieKey` option to whatever you'd like, the default is _i18n_redirected_.

```js {}[nuxt.config.js]
['nuxt-i18n', {
['@nuxtjs/i18n', {
// ...
detectBrowserLanguage: {
useCookie: true,
Expand All @@ -41,7 +41,7 @@ To prevent redirecting users every time they visit the app, **nuxt-i18n** sets a
If you'd rather have users be redirected to their browser's language every time they visit the app, disable the cookie by setting `detectBrowserLanguage.useCookie` to `false`.

```js {}[nuxt.config.js]
['nuxt-i18n', {
['@nuxtjs/i18n', {
// ...
detectBrowserLanguage: {
useCookie: false
Expand All @@ -52,7 +52,7 @@ If you'd rather have users be redirected to their browser's language every time
To completely disable the browser's language detection feature, set `detectBrowserLanguage` to `false`.

```js {}[nuxt.config.js]
['nuxt-i18n', {
['@nuxtjs/i18n', {
// ...
detectBrowserLanguage: false
}]
Expand All @@ -61,7 +61,7 @@ To completely disable the browser's language detection feature, set `detectBrows
To redirect the user every time they visit the app and keep their selected choice, enable alwaysRedirect:

```js {}[nuxt.config.js]
['nuxt-i18n', {
['@nuxtjs/i18n', {
// ...
detectBrowserLanguage: {
useCookie: true,
Expand All @@ -73,7 +73,7 @@ To redirect the user every time they visit the app and keep their selected choic
To use the cookie within a cross-origin environment (e.g. in an iFrame), you can set `cookieCrossOrigin: true`. This will change the cookie settings from `SameSite=Lax` to `SameSite=None; Secure`.

```js {}[nuxt.config.js]
['nuxt-i18n', {
['@nuxtjs/i18n', {
// ...
detectBrowserLanguage: {
useCookie: true,
Expand Down
4 changes: 2 additions & 2 deletions docs/content/en/callbacks.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: Callbacks
description: "**nuxt-i18n** exposes some callbacks that you can use to perform specific tasks that depend on the app's language."
description: "**@nuxtjs/i18n** exposes some callbacks that you can use to perform specific tasks that depend on the app's language."
position: 5
category: Guide
---

**nuxt-i18n** exposes some callbacks that you can use to perform specific tasks that depend on the app's language.
**@nuxtjs/i18n** exposes some callbacks that you can use to perform specific tasks that depend on the app's language.

### onBeforeLanguageSwitch

Expand Down
4 changes: 2 additions & 2 deletions docs/content/en/different-domains.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You might want to use a different domain name for each language your app support
</alert>

```js {}[nuxt.config.js]
['nuxt-i18n', {
['@nuxtjs/i18n', {
locales: [
{
code: 'en',
Expand Down Expand Up @@ -73,7 +73,7 @@ module.exports = {
const localeDomains = require('./config/locale-domains')
//...
[
'nuxt-i18n',
'@nuxtjs/i18n',
{
differentDomains: process.env.NODE_ENV === 'production',
locales: [
Expand Down
12 changes: 6 additions & 6 deletions docs/content/en/lang-switcher.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: Lang Switcher
description: "When **nuxt-i18n** loads in your app, it adds your `locales` configuration to `this.$i18n` (or `app.i18n`), which makes it really easy to display a lang switcher anywhere in your app."
description: "When **@nuxtjs/i18n** loads in your app, it adds your `locales` configuration to `this.$i18n` (or `app.i18n`), which makes it really easy to display a lang switcher anywhere in your app."
position: 10
category: Guide
---

When **nuxt-i18n** loads in your app, it adds your `locales` configuration to `this.$i18n` (or `app.i18n`), which makes it really easy to display a lang switcher anywhere in your app.
When **@nuxtjs/i18n** loads in your app, it adds your `locales` configuration to `this.$i18n` (or `app.i18n`), which makes it really easy to display a lang switcher anywhere in your app.

Here's an example lang switcher where a `name` key has been added to each locale object in order to display friendlier titles for each link:

Expand All @@ -25,7 +25,7 @@ computed: {
```

```js {}[nuxt.config.js]
['nuxt-i18n', {
['@nuxtjs/i18n', {
locales: [
{
code: 'en',
Expand Down Expand Up @@ -61,11 +61,11 @@ The template code might look like this, for example:

## Dynamic route parameters

Dealing with dynamic route parameters requires a bit more work because you need to provide parameters translations to **nuxt-i18n**. For this purpose, **nuxt-i18n**'s store module exposes a `routeParams` state property that will be merged with route params when generating lang switch routes with `switchLocalePath()`.
Dealing with dynamic route parameters requires a bit more work because you need to provide parameters translations to **@nuxtjs/i18n**. For this purpose, **@nuxtjs/i18n**'s store module exposes a `routeParams` state property that will be merged with route params when generating lang switch routes with `switchLocalePath()`.

<alert type="warning">

Make sure that Vuex [is enabled](https://nuxtjs.org/guides/directory-structure/store) in your app and that you did not set `vuex` option to `false` in **nuxt-i18n**'s options.
Make sure that Vuex [is enabled](https://nuxtjs.org/guides/directory-structure/store) in your app and that you did not set `vuex` option to `false` in **@nuxtjs/i18n**'s options.

</alert>

Expand Down Expand Up @@ -95,7 +95,7 @@ export default {

<alert type="info">

**nuxt-i18n** won't reset parameters translations for you, this means that if you use identical parameters for different routes, navigating between those routes might result in conflicting parameters. Make sure you always set params translations in such cases.
**@nuxtjs/i18n** won't reset parameters translations for you, this means that if you use identical parameters for different routes, navigating between those routes might result in conflicting parameters. Make sure you always set params translations in such cases.

</alert>

Expand Down
8 changes: 4 additions & 4 deletions docs/content/en/lazy-load-translations.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ category: Guide
---

For apps that contain a lot of translated content, it is preferable not to bundle all the messages in the main bundle but rather lazy-load only the language that the users selected.
This can be achieved with **nuxt-i18n** by letting the module know where your translation files are located so it can dynamically import them when the app loads or when the user switches to another language.
To enable translations lazy-loading, follow these steps when configuring **nuxt-i18n**:
This can be achieved with **@nuxtjs/i18n** by letting the module know where your translation files are located so it can dynamically import them when the app loads or when the user switches to another language.
To enable translations lazy-loading, follow these steps when configuring **@nuxtjs/i18n**:

* Set `lazy` option to `true` (or to [configuration object](#lazy-configuration-options) if you want to customize some options).
* Set `langDir` option to the directory (can not be empty) that contains your translation files.
Expand All @@ -29,7 +29,7 @@ nuxt-project/
Configuration example:

```js {}[nuxt.config.js]
['nuxt-i18n', {
['@nuxtjs/i18n', {
locales: [
{
code: 'en',
Expand Down Expand Up @@ -68,7 +68,7 @@ export default {

<alert type="info">

Note that if you want to use the `$axios` instance from the `@nuxtjs/axios` module within the exported function, the `@nuxtjs/axios` module must be registered **after** the `nuxt-i18n` module.
Note that if you want to use the `$axios` instance from the `@nuxtjs/axios` module within the exported function, the `@nuxtjs/axios` module must be registered **after** the `@nuxtjs/i18n` module.

This rule in fact applies also to any other module that adds plugins and whose functionality you'd want to use from within that function.

Expand Down
4 changes: 2 additions & 2 deletions docs/content/en/locale-fallback.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ position: 12
category: Guide
---

**nuxt-i18n** takes advantage of **vue-i18n** ability to handle localization fallback. It is possible to define a single fallback locale, an array of locales,
**@nuxtjs/i18n** takes advantage of **vue-i18n** ability to handle localization fallback. It is possible to define a single fallback locale, an array of locales,
or a decision map for more specific needs.

```js [nuxt.config.js]
modules: [
'nuxt-i18n'
'@nuxtjs/i18n'
],

i18n: {
Expand Down
8 changes: 4 additions & 4 deletions docs/content/en/options-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ position: 4
category: Getting started
---

You can configure **nuxt-i18n** with the `i18n` property in your `nuxt.config.js` or by passing options inline with the module declaration:
You can configure **@nuxtjs/i18n** with the `i18n` property in your `nuxt.config.js` or by passing options inline with the module declaration:

```js {}[nuxt.config.js]
export default {
modules: [
'nuxt-i18n',
'@nuxtjs/i18n',
],
i18n: {
// Options
Expand All @@ -21,7 +21,7 @@ export default {

export default {
modules: [
['nuxt-i18n', {
['@nuxtjs/i18n', {
// Options
}],
],
Expand Down Expand Up @@ -111,7 +111,7 @@ When using `prefix_except_default` strategy, URLs for locale specified here won'

Whether to sort routes by using the `sortRoutes` function from the `@nuxt/utils` package.

While Nuxt sorts the routes itself, it does that before **nuxt-i18n** has added its own generated routes so the module has to re-sort them again. This is necessary as otherwise some routes might become inaccessible due to being shadowed by more generic routes. If you are adding custom routes programmatically, the sorting might change the order of your custom routes in unexpected ways so in that case you might want to disable sorting and handle that yourself. In that case you have to ensure the correct order yourself so that, for example, a more generic route like `/en/*` doesn't shadow a more specific `/en/foo/*` route (the latter should be registered first to work properly).
While Nuxt sorts the routes itself, it does that before **@nuxtjs/i18n** has added its own generated routes so the module has to re-sort them again. This is necessary as otherwise some routes might become inaccessible due to being shadowed by more generic routes. If you are adding custom routes programmatically, the sorting might change the order of your custom routes in unexpected ways so in that case you might want to disable sorting and handle that yourself. In that case you have to ensure the correct order yourself so that, for example, a more generic route like `/en/*` doesn't shadow a more specific `/en/foo/*` route (the latter should be registered first to work properly).

## `strategy`

Expand Down
4 changes: 2 additions & 2 deletions docs/content/en/per-component-translations.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ position: 13
category: Guide
---

If you'd like to define translations per-page or per-component you can take advantage of the [vue-i18n-loader](https://github.com/intlify/vue-i18n-loader). Simply set `vueI18nLoader` option to `true` and `nuxt-i18n` will configure and enable the loader for you, including support for Yaml syntax in the `i18n` blocks.
If you'd like to define translations per-page or per-component you can take advantage of the [vue-i18n-loader](https://github.com/intlify/vue-i18n-loader). Simply set `vueI18nLoader` option to `true` and `@nuxtjs/i18n` will configure and enable the loader for you, including support for Yaml syntax in the `i18n` blocks.

```js {}[nuxt.config.js]
['nuxt-i18n', {
['@nuxtjs/i18n', {
vueI18nLoader: true
}]

Expand Down
Loading

0 comments on commit b3ef21c

Please sign in to comment.