mirror of
				https://github.com/elyby/accounts-frontend.git
				synced 2025-05-31 14:11:58 +05:30 
			
		
		
		
	Fix locales flags overriding
This commit is contained in:
		@@ -19,11 +19,6 @@ export function getCountriesList(): string[] {
 | 
			
		||||
    return SUPPORTED_LANGUAGES.map((locale) => localeToCountryCode[locale] || locale);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const flagIconLoadingChain: ReadonlyArray<(locale: string) => { default: string }> = [
 | 
			
		||||
    (locale) => require(`./flags/${locale}.svg`),
 | 
			
		||||
    (locale) => require(`flag-icon-css/flags/4x3/${localeToCountryCode[locale] || locale}.svg`),
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Возвращает для указанной локали её флаг с учётом всех нюансов загрузки флага
 | 
			
		||||
 * и подбора соответствующего локали флага.
 | 
			
		||||
@@ -33,13 +28,12 @@ const flagIconLoadingChain: ReadonlyArray<(locale: string) => { default: string
 | 
			
		||||
 * @returns {string}
 | 
			
		||||
 */
 | 
			
		||||
export function getLocaleIconUrl(locale: string): string {
 | 
			
		||||
    for (const flagIconLoadingChainElement of flagIconLoadingChain) {
 | 
			
		||||
        try {
 | 
			
		||||
            return flagIconLoadingChainElement(locale).default;
 | 
			
		||||
        } catch (err) {
 | 
			
		||||
            if (!err.message.startsWith('Cannot find module')) {
 | 
			
		||||
                throw err;
 | 
			
		||||
            }
 | 
			
		||||
    try {
 | 
			
		||||
        // eslint-disable-next-line @typescript-eslint/no-var-requires
 | 
			
		||||
        return require(`flag-icon-css/flags/4x3/${localeToCountryCode[locale] || locale}.svg`).default;
 | 
			
		||||
    } catch (err) {
 | 
			
		||||
        if (!err.message.startsWith('Cannot find module')) {
 | 
			
		||||
            throw err;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user