Skip to content

Commit

Permalink
move
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl committed Mar 9, 2021
1 parent 5a8b1d9 commit cf8d95c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
15 changes: 0 additions & 15 deletions src/core/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,6 @@ export function createExtendRoutesHook (moduleContainer, options) {
}

export function buildHook (moduleContainer, options) {
if (options.lazy) {
if (!options.langDir) {
throw new Error(`[${MODULE_NAME}] When using the "lazy" option you must also set the "langDir" option.`)
}
if (!options.locales.length || typeof options.locales[0] === 'string') {
throw new Error(`[${MODULE_NAME}] When using the "langDir" option the "locales" option must be a list of objects.`)
}
for (const locale of options.locales) {
if (!locale[LOCALE_FILE_KEY]) {
throw new Error(`[${MODULE_NAME}] All locale objects must have the "file" property set when using "lazy".\nFound none in:\n${JSON.stringify(locale, null, 2)}.`)
}
}
options.langDir = moduleContainer.nuxt.resolver.resolveAlias(options.langDir)
}

if (options.strategy === STRATEGIES.NO_PREFIX && options.differentDomains) {
// eslint-disable-next-line no-console
console.warn('[' + MODULE_NAME + '] The `differentDomains` option and `no_prefix` strategy are not compatible. Change strategy or disable `differentDomains` option.')
Expand Down
15 changes: 15 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ export default function (userOptions) {
return
}

if (options.lazy) {
if (!options.langDir) {
throw new Error(`[${MODULE_NAME}] When using the "lazy" option you must also set the "langDir" option.`)
}
if (!options.locales.length || typeof options.locales[0] === 'string') {
throw new Error(`[${MODULE_NAME}] When using the "langDir" option the "locales" option must be a list of objects.`)
}
for (const locale of options.locales) {
if (!locale[LOCALE_FILE_KEY]) {
throw new Error(`[${MODULE_NAME}] All locale objects must have the "file" property set when using "lazy".\nFound none in:\n${JSON.stringify(locale, null, 2)}.`)
}
}
options.langDir = this.nuxt.resolver.resolveAlias(options.langDir)
}

// Templates (including plugins).
// This is done here rather than in the build hook to ensure the order the plugins are added
// is predictable between different modules.
Expand Down

0 comments on commit cf8d95c

Please sign in to comment.