Skip to content

Commit

Permalink
fix(validator): fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed May 24, 2021
1 parent b4cda4c commit b1a83d2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/validator/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ const getBrowserlanguage = () => {
const registry = {
locales: {
messages: {},
langugage: getBrowserlanguage(),
language: getBrowserlanguage(),
},
formats: {},
rules: {},
template: null,
}

const getISOCode = (langugage: string) => {
let isoCode = registry.locales.langugage
if (registry.locales.messages[langugage]) {
return langugage
const getISOCode = (language: string) => {
let isoCode = registry.locales.language
if (registry.locales.messages[language]) {
return language
}
each(
registry.locales.messages,
(messages: IRegistryLocaleMessages, key: string) => {
if (key.indexOf(langugage) > -1 || String(langugage).indexOf(key) > -1) {
if (key.indexOf(language) > -1 || String(language).indexOf(key) > -1) {
isoCode = key
return false
}
Expand All @@ -55,15 +55,15 @@ const getISOCode = (langugage: string) => {
}

export const setValidateLanguage = (lang: string) => {
registry.locales.langugage = lang
registry.locales.language = lang
}

export const getValidateLanguage = () => registry.locales.langugage
export const getValidateLanguage = () => registry.locales.language

export const getValidateLocale = (path: string) => {
const message = getIn(
registry.locales.messages,
`${getISOCode(registry.locales.langugage)}.${path}`
`${getISOCode(registry.locales.language)}.${path}`
)
return message || getValidateLocale('pattern')
}
Expand Down

0 comments on commit b1a83d2

Please sign in to comment.