-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3728 from gibkigonzo/feature/remove-prefech-dayjs…
…-locales remove prefech dayjs locales
- Loading branch information
Showing
5 changed files
with
54 additions
and
14 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
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
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,29 @@ | ||
import config from 'config' | ||
|
||
export const currentBuildLocales = (): string[] => { | ||
const defaultLocale = config.i18n.defaultLocale || 'en-US' | ||
const multistoreLocales = config.storeViews.multistore | ||
? Object.values(config.storeViews) | ||
.map((store: any) => store && typeof store === 'object' && store.i18n && store.i18n.defaultLocale) | ||
.filter(Boolean) | ||
: [] | ||
const locales = multistoreLocales.includes(defaultLocale) | ||
? multistoreLocales | ||
: [defaultLocale, ...multistoreLocales] | ||
|
||
return locales | ||
} | ||
|
||
export const transformToShortLocales = (locales: string[]): string[] => locales.map(locale => { | ||
const separatorIndex = locale.indexOf('-') | ||
const shortLocale = separatorIndex ? locale.substr(0, separatorIndex) : locale | ||
|
||
return shortLocale | ||
}) | ||
|
||
export const buildLocaleIgnorePattern = (): RegExp => { | ||
const locales = transformToShortLocales(currentBuildLocales()) | ||
const localesRegex = locales.map(locale => `${locale}$`).join('|') | ||
|
||
return new RegExp(localesRegex) | ||
} |
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
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