Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nuxt-i18n

Package Overview
Dependencies
Maintainers
2
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuxt-i18n - npm Package Compare versions

Comparing version 6.9.3 to 6.10.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [6.10.0](https://github.com/nuxt-community/nuxt-i18n/compare/v6.9.3...v6.10.0) (2020-04-23)
### Features
* allow providing function for baseUrl option ([#679](https://github.com/nuxt-community/nuxt-i18n/issues/679)) ([056a8f7](https://github.com/nuxt-community/nuxt-i18n/commit/056a8f727b678fbe64496d2fb82af08443fe471c))
### [6.9.3](https://github.com/nuxt-community/nuxt-i18n/compare/v6.9.1...v6.9.3) (2020-04-23)

@@ -2,0 +9,0 @@

6

package.json
{
"name": "nuxt-i18n",
"version": "6.9.3",
"version": "6.10.0",
"description": "i18n for Nuxt",

@@ -83,2 +83,3 @@ "license": "MIT",

"@babel/traverse": "^7.5.5",
"@intlify/vue-i18n-extensions": "^1.0.1",
"@intlify/vue-i18n-loader": "^1.0.0",

@@ -88,4 +89,3 @@ "cookie": "^0.4.0",

"js-cookie": "^2.2.1",
"vue-i18n": "^8.17.3",
"vue-i18n-extensions": "^0.2.1"
"vue-i18n": "^8.17.3"
},

@@ -92,0 +92,0 @@ "devDependencies": {

const { resolve, join } = require('path')
const { readdirSync } = require('fs')
const i18nExtensions = require('vue-i18n-extensions')
const { directive: i18nExtensionsDirective } = require('@intlify/vue-i18n-extensions')

@@ -140,3 +140,3 @@ const {

this.options.render.bundleRenderer.directives = this.options.render.bundleRenderer.directives || {}
this.options.render.bundleRenderer.directives.t = i18nExtensions.directive
this.options.render.bundleRenderer.directives.t = i18nExtensionsDirective
}

@@ -7,2 +7,3 @@ import Cookie from 'cookie'

import {
baseUrl,
beforeLanguageSwitch,

@@ -28,3 +29,3 @@ defaultLocale,

} from './utils'
import { matchBrowserLocale, parseAcceptLanguage } from './utils-common'
import { resolveBaseUrl, matchBrowserLocale, parseAcceptLanguage } from './utils-common'

@@ -202,2 +203,3 @@ Vue.use(VueI18n)

app.i18n.defaultLocale = defaultLocale
app.i18n.__baseUrl = resolveBaseUrl(baseUrl, context)
app.i18n.differentDomains = differentDomains

@@ -204,0 +206,0 @@ app.i18n.beforeLanguageSwitch = beforeLanguageSwitch

import middleware from '../middleware'
import { detectBrowserLanguage, rootRedirect } from './options'
import { baseUrl, detectBrowserLanguage, rootRedirect } from './options'
import { getLocaleFromRoute } from './utils'
import { resolveBaseUrl } from './utils-common'

@@ -26,2 +27,4 @@ middleware.nuxti18n = async (context) => {

app.i18n.__baseUrl = resolveBaseUrl(baseUrl, context)
if (detectBrowserLanguage && await app.i18n.__detectBrowserLanguage()) {

@@ -28,0 +31,0 @@ return

import VueMeta from 'vue-meta'
import {
baseUrl,
COMPONENT_OPTIONS_KEY,

@@ -37,4 +36,4 @@ LOCALE_CODE_KEY,

addHreflangLinks.bind(this)(this.$i18n.locales, metaObject.link)
addCanonicalLinks.bind(this)(currentLocale, metaObject.link)
addHreflangLinks.bind(this)(this.$i18n.locales, this.$i18n.__baseUrl, metaObject.link)
addCanonicalLinks.bind(this)(currentLocale, this.$i18n.__baseUrl, metaObject.link)
addCurrentOgLocale.bind(this)(currentLocale, currentLocaleIso, metaObject.meta)

@@ -46,3 +45,3 @@ addAlternateOgLocales.bind(this)(this.$i18n.locales, currentLocaleIso, metaObject.meta)

function addHreflangLinks (locales, link) {
function addHreflangLinks (locales, baseUrl, link) {
if (strategy === STRATEGIES.NO_PREFIX) {

@@ -82,3 +81,3 @@ return

function addCanonicalLinks (currentLocale, link) {
function addCanonicalLinks (currentLocale, baseUrl, link) {
if (strategy !== STRATEGIES.PREFIX_AND_DEFAULT) {

@@ -85,0 +84,0 @@ return

@@ -5,3 +5,3 @@ /**

* @return {string[]} An array of locale codes. Priority determined by order in array.
**/
*/
export const parseAcceptLanguage = input => {

@@ -21,3 +21,3 @@ // Example input: en-US,en;q=0.9,nb;q=0.8,no;q=0.7

* @return {string?}
**/
*/
export const matchBrowserLocale = (appLocales, browserLocales) => {

@@ -64,1 +64,15 @@ /** @type {{ code: string, score: number }[]} */

}
/**
* Resolves base URL value if provided as function. Otherwise just returns verbatim.
* @param {string | function} baseUrl
* @param {import('@nuxt/types').Context} context
* @return {string}
*/
export const resolveBaseUrl = (baseUrl, context) => {
if (typeof baseUrl === 'function') {
return baseUrl(context)
}
return baseUrl
}
import VueI18n from 'vue-i18n'
import { MetaInfo } from 'vue-meta'
import { Context as NuxtContext } from '@nuxt/types'

@@ -60,3 +61,3 @@ /**

interface AllOptionsInterface extends NuxtI18nInterface {
baseUrl?: string
baseUrl?: (context: NuxtContext) => string | string
detectBrowserLanguage?: DetectBrowserLanguageInterface

@@ -63,0 +64,0 @@ encodePaths?: boolean

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc