-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(types): export
NuxtVueI18n
namespace to allow to annotate confi…
…guration Also moved nuxt specific types to new file and leave `vue.d.ts` for types that extend vue and nuxt.
- Loading branch information
Showing
3 changed files
with
99 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
// augment typings of Vue.js | ||
import "./vue"; | ||
import './vue' | ||
|
||
export { NuxtVueI18n } from './nuxt-i18n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import VueI18n, { IVueI18n } from 'vue-i18n' | ||
import { MetaInfo } from 'vue-meta' | ||
|
||
/** | ||
* The nuxt-i18n types namespace | ||
*/ | ||
declare namespace NuxtVueI18n { | ||
type Locale = VueI18n.Locale | ||
|
||
namespace Options { | ||
// e.g.: | ||
// [ | ||
// { code: 'en', iso: 'en-US', file: 'en.js' }, | ||
// { code: 'fr', iso: 'fr-FR', file: 'fr.js' }, | ||
// { code: 'es', iso: 'es-ES', file: 'es.js' } | ||
// ] | ||
interface LocaleObject { | ||
code: Locale | ||
// can be undefined: https://goo.gl/cCGKUV | ||
iso?: string | ||
// can be undefined: https://goo.gl/ryc5pF | ||
file?: string | ||
// Allow custom properties, e.g. "name": https://goo.gl/wrcb2G | ||
[key: string]: any | ||
} | ||
|
||
interface DetectBrowserLanguageInterface { | ||
useCookie?: boolean | ||
cookieKey?: string | ||
alwaysRedirect?: boolean | ||
fallbackLocale?: Locale | null | ||
} | ||
|
||
interface VuexInterface { | ||
moduleName?: string | ||
syncLocale?: boolean | ||
syncMessages?: boolean | ||
syncRouteParams?: boolean | ||
} | ||
|
||
// options that are also exposed on VueI18n instance: https://goo.gl/UwNfZo | ||
interface NuxtI18nInterface { | ||
beforeLanguageSwitch?: () => any | ||
defaultLocale?: null | Locale | ||
locales?: Array<Locale | LocaleObject> | ||
differentDomains?: boolean | ||
forwardedHost?: boolean | ||
onLanguageSwitched?: () => any | ||
} | ||
|
||
// see options reference: https://github.com/nuxt-community/nuxt-i18n/blob/master/docs/options-reference.md | ||
interface AllOptionsInterface extends NuxtI18nInterface { | ||
baseUrl?: string | ||
detectBrowserLanguage?: DetectBrowserLanguageInterface | ||
encodePaths?: boolean | ||
langDir?: string | null | ||
lazy?: boolean | ||
// see https://goo.gl/NbzX3f | ||
pages?: { | ||
[key: string]: boolean | { | ||
[key: string]: boolean | string | ||
} | ||
} | ||
parsePages?: boolean | ||
rootRedirect?: string | null | ||
routesNameSeparator?: string | ||
seo?: boolean | ||
strategy?: 'no_prefix' | 'prefix_except_default' | 'prefix' | 'prefix_and_default' | ||
vueI18n?: VueI18n.I18nOptions | ||
vuex?: VuexInterface | ||
} | ||
} | ||
} | ||
|
||
export interface NuxtI18nSeo { | ||
htmlAttrs?: MetaInfo['htmlAttrs'] | ||
link?: MetaInfo['link'] | ||
meta?: MetaInfo['meta'] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters