Files
mastodon/app/javascript/flavours/glitch/features/emoji/locale.ts
Echo 8a8453e3b1 [Glitch] Emoji Rendering
Port 760d00b7f7 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2025-07-23 19:05:04 +02:00

24 lines
674 B
TypeScript

import type { Locale } from 'emojibase';
import { SUPPORTED_LOCALES } from 'emojibase';
import type { LocaleOrCustom } from './types';
export function toSupportedLocale(localeBase: string): Locale {
const locale = localeBase.toLowerCase();
if (isSupportedLocale(locale)) {
return locale;
}
return 'en'; // Default to English if unsupported
}
export function toSupportedLocaleOrCustom(locale: string): LocaleOrCustom {
if (locale.toLowerCase() === 'custom') {
return 'custom';
}
return toSupportedLocale(locale);
}
function isSupportedLocale(locale: string): locale is Locale {
return SUPPORTED_LOCALES.includes(locale.toLowerCase() as Locale);
}