nuxt-i18n
Advanced tools
Comparing version 6.13.9 to 6.13.10
@@ -0,1 +1,9 @@ | ||
### [6.13.10](https://github.com/nuxt-community/i18n-module/compare/v6.13.9...v6.13.10) (2020-08-18) | ||
### Bug Fixes | ||
* **routes:** fix routes being generated after other modules ([#851](https://github.com/nuxt-community/i18n-module/issues/851)) ([b453191](https://github.com/nuxt-community/i18n-module/commit/b45319182d07c471ef871d0a59cdb952ccff5803)), closes [#850](https://github.com/nuxt-community/i18n-module/issues/850) | ||
* **types:** add types for app.localePath and co. ([#849](https://github.com/nuxt-community/i18n-module/issues/849)) ([dfd6d76](https://github.com/nuxt-community/i18n-module/commit/dfd6d76d3082e28ed42040df218e0b71b93eb590)) | ||
### [6.13.9](https://github.com/nuxt-community/i18n-module/compare/v6.13.8...v6.13.9) (2020-08-15) | ||
@@ -2,0 +10,0 @@ |
{ | ||
"name": "nuxt-i18n", | ||
"version": "6.13.9", | ||
"version": "6.13.10", | ||
"description": "i18n for Nuxt", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -6,5 +6,33 @@ import { resolve, join } from 'path' | ||
export async function buildHook (moduleContainer, options) { | ||
export async function createExtendRoutesHook (moduleContainer, options) { | ||
const nuxtOptions = moduleContainer.options | ||
let includeUprefixedFallback = nuxtOptions.target === 'static' | ||
// Doesn't seem like we can tell whether we are in nuxt generate from the module so we'll | ||
// take advantage of the 'generate:before' hook to store variable. | ||
moduleContainer.nuxt.hook('generate:before', () => { includeUprefixedFallback = true }) | ||
const pagesDir = nuxtOptions.dir && nuxtOptions.dir.pages ? nuxtOptions.dir.pages : 'pages' | ||
const { trailingSlash } = nuxtOptions.router | ||
// This import (or more specifically 'vue-template-compiler' in helpers/components.js) needs to | ||
// be required only at build time to avoid problems when 'vue-template-compiler' dependency is | ||
// not available (at runtime, when using nuxt-start). | ||
const { makeRoutes } = await import('../helpers/routes') | ||
return routes => { | ||
const localizedRoutes = makeRoutes(routes, { | ||
...options, | ||
pagesDir, | ||
includeUprefixedFallback, | ||
trailingSlash | ||
}) | ||
routes.splice(0, routes.length) | ||
routes.unshift(...localizedRoutes) | ||
} | ||
} | ||
export function buildHook (moduleContainer, options) { | ||
const nuxtOptions = moduleContainer.options | ||
// Copy lang files to the build directory. | ||
@@ -34,27 +62,3 @@ if (options.langDir) { | ||
const pagesDir = nuxtOptions.dir && nuxtOptions.dir.pages ? nuxtOptions.dir.pages : 'pages' | ||
if (options.strategy !== STRATEGIES.NO_PREFIX) { | ||
if (localeCodes.length) { | ||
let includeUprefixedFallback = nuxtOptions.target === 'static' | ||
// Doesn't seem like we can tell whether we are in nuxt generate from the module so we'll | ||
// take advantage of the 'generate:before' hook to store variable. | ||
moduleContainer.nuxt.hook('generate:before', () => { includeUprefixedFallback = true }) | ||
// This import (or more specifically 'vue-template-compiler' in helpers/components.js) needs to | ||
// be required only at build time to avoid problems when 'vue-template-compiler' dependency is | ||
// not available (at runtime, when using nuxt-start). | ||
const { makeRoutes } = await import('../helpers/routes') | ||
moduleContainer.extendRoutes(routes => { | ||
const localizedRoutes = makeRoutes(routes, { | ||
...options, | ||
pagesDir, | ||
includeUprefixedFallback, | ||
trailingSlash | ||
}) | ||
routes.splice(0, routes.length) | ||
routes.unshift(...localizedRoutes) | ||
}) | ||
} | ||
} else if (options.differentDomains) { | ||
if (options.strategy === STRATEGIES.NO_PREFIX && options.differentDomains) { | ||
// eslint-disable-next-line no-console | ||
@@ -61,0 +65,0 @@ console.warn('[' + MODULE_NAME + '] The `differentDomains` option and `no_prefix` strategy are not compatible. Change strategy or disable `differentDomains` option.') |
import { directive as i18nExtensionsDirective } from '@intlify/vue-i18n-extensions' | ||
import { MODULE_NAME, DEFAULT_OPTIONS, NESTED_OPTIONS, STRATEGIES } from './helpers/constants' | ||
import { buildHook } from './core/hooks' | ||
import { getLocaleCodes } from './helpers/utils' | ||
import { buildHook, createExtendRoutesHook } from './core/hooks' | ||
module.exports = function (userOptions) { | ||
export default async function (userOptions) { | ||
const options = { ...DEFAULT_OPTIONS, ...userOptions, ...this.options.i18n } | ||
@@ -21,2 +22,7 @@ // Options that have nested config options must be merged | ||
const localeCodes = getLocaleCodes(options.locales) | ||
if (options.strategy !== STRATEGIES.NO_PREFIX && localeCodes.length) { | ||
this.extendRoutes(await createExtendRoutesHook(this, options)) | ||
} | ||
this.nuxt.hook('build:before', () => buildHook(this, options)) | ||
@@ -23,0 +29,0 @@ |
@@ -24,9 +24,8 @@ import Vue from 'vue' | ||
interface Vue { | ||
readonly $i18n: VueI18n & IVueI18n | ||
$nuxtI18nSeo(): NuxtI18nSeo | ||
getRouteBaseName(route?: Route): string | ||
localePath(route: RawLocation, locale?: string): string | ||
localeRoute(route: RawLocation, locale?: string): Location | undefined | ||
switchLocalePath(locale: string): string | ||
getRouteBaseName(route?: Route): string | ||
$nuxtI18nSeo(): NuxtI18nSeo | ||
// PHPStorm without this indicates that "$i18n" was not found. | ||
readonly $i18n: VueI18n & IVueI18n | ||
} | ||
@@ -47,2 +46,6 @@ } | ||
readonly i18n: VueI18n & IVueI18n | ||
getRouteBaseName(route?: Route): string | ||
localePath(route: RawLocation, locale?: string): string | ||
localeRoute(route: RawLocation, locale?: string): Location | undefined | ||
switchLocalePath(locale: string): string | ||
} | ||
@@ -49,0 +52,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116224
1454