Skip to content

Commit a7ea4df

Browse files
committed
feat(strategy): add PREFIX_AND_DEFAULT strategy
1 parent 71f8004 commit a7ea4df

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/helpers/constants.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export const LOCALE_FILE_KEY = 'file'
1414
// Options
1515
export const STRATEGIES = {
1616
PREFIX: 'prefix',
17-
PREFIX_EXCEPT_DEFAULT: 'prefix_except_default'
17+
PREFIX_EXCEPT_DEFAULT: 'prefix_except_default',
18+
PREFIX_AND_DEFAULT: 'prefix_and_default'
1819
}
1920
export const COMPONENT_OPTIONS_KEY = 'nuxtI18n'
2021
export const DEFAULT_OPTIONS = {

src/helpers/routes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,19 @@ export const makeRoutes = (baseRoutes, {
8888
// Skip default locale if strategy is PREFIX_EXCEPT_DEFAULT
8989
!(locale === defaultLocale && strategy === STRATEGIES.PREFIX_EXCEPT_DEFAULT)
9090
)
91+
92+
if (locale === defaultLocale && strategy === STRATEGIES.PREFIX_AND_DEFAULT) {
93+
routes.push({...localizedRoute, path})
94+
}
95+
9196
if (shouldAddPrefix) {
9297
path = `/${locale}${path}`
9398
}
9499

95100
localizedRoute.path = path
96101

97102
routes.push(localizedRoute)
103+
98104
}
99105

100106
return routes

0 commit comments

Comments
 (0)