-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fall back to overall language [DHIS2-17696]
- Loading branch information
Showing
18 changed files
with
187 additions
and
135 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
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,22 @@ | ||
import { parseLocale, getLngsArray } from '../locales.js' | ||
|
||
describe('parseLocale', () => { | ||
it('handles one _', () => { | ||
expect(parseLocale('en_LK')).toBe('en-LK') | ||
}) | ||
it('handles multiple _', () => { | ||
expect(parseLocale('mn_MN_Cyrl')).toBe('mn-MN-Cyrl') | ||
}) | ||
it('handles no _', () => { | ||
expect(parseLocale('id')).toBe('id') | ||
}) | ||
}) | ||
|
||
describe('getLngsArray', () => { | ||
it('adds language from multipart locale', () => { | ||
expect(getLngsArray('fr_CA')).toEqual(['fr_CA', 'fr']) | ||
}) | ||
it('returns array with just language when locale is only language', () => { | ||
expect(getLngsArray('fr')).toEqual(['fr']) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { checkIsLoginFormValid, getIsRequired } from './validators.js' | ||
export { convertHTML, removeHTMLTags, sanitizeMainHTML } from './handleHTML.js' | ||
export { redirectTo, getRedirectString } from './redirectHelpers.js' | ||
export { parseLocale, getLngsArray } from './locales.js' |
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,7 @@ | ||
export const parseLocale = (unparsedLocale) => | ||
unparsedLocale?.replaceAll('_', '-') | ||
|
||
export const getLngsArray = (locale) => { | ||
const [lng] = locale.split('_') | ||
return lng === locale ? [locale] : [locale, lng] | ||
} |
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
Oops, something went wrong.