Skip to content

Commit

Permalink
feat(strategy): add PREFIX_AND_DEFAULT strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
odanado committed Jul 22, 2018
1 parent 71f8004 commit a7ea4df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export const LOCALE_FILE_KEY = 'file'
// Options
export const STRATEGIES = {
PREFIX: 'prefix',
PREFIX_EXCEPT_DEFAULT: 'prefix_except_default'
PREFIX_EXCEPT_DEFAULT: 'prefix_except_default',
PREFIX_AND_DEFAULT: 'prefix_and_default'
}
export const COMPONENT_OPTIONS_KEY = 'nuxtI18n'
export const DEFAULT_OPTIONS = {
Expand Down
6 changes: 6 additions & 0 deletions src/helpers/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,19 @@ export const makeRoutes = (baseRoutes, {
// Skip default locale if strategy is PREFIX_EXCEPT_DEFAULT
!(locale === defaultLocale && strategy === STRATEGIES.PREFIX_EXCEPT_DEFAULT)
)

if (locale === defaultLocale && strategy === STRATEGIES.PREFIX_AND_DEFAULT) {
routes.push({...localizedRoute, path})
}

if (shouldAddPrefix) {
path = `/${locale}${path}`
}

localizedRoute.path = path

routes.push(localizedRoute)

}

return routes
Expand Down

0 comments on commit a7ea4df

Please sign in to comment.