1 import IntlMessageFormat from 'intl-messageformat'
2 import { logger } from '@root-helpers/logger'
3 import { environment } from '../../environments/environment'
5 function isOnDevLocale () {
6 return environment.production === false && window.location.search === '?lang=fr'
9 function getDevLocale () {
13 function prepareIcu (icu: string) {
14 let alreadyWarned = false
17 const msg = new IntlMessageFormat(icu, $localize.locale)
19 return (context: { [id: string]: number | string }, fallback: string) => {
21 return msg.format(context) as string
23 if (!alreadyWarned) logger.warn(`Cannot format ICU ${icu}.`, err)
30 logger.warn(`Cannot build intl message ${icu}.`, err)
32 return (_context: unknown, fallback: string) => fallback