mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-29 04:43:26 +01:00
Fallback to emoji-datasource for unlocalized emoji
This commit is contained in:
@@ -23,7 +23,8 @@ export type FunEmojiLocalizer = Readonly<{
|
||||
}>;
|
||||
|
||||
export function createFunEmojiLocalizerIndex(
|
||||
localeEmojiList: LocaleEmojiListType
|
||||
localeEmojiList: LocaleEmojiListType,
|
||||
defaultLocalizerIndex?: FunEmojiLocalizerIndex
|
||||
): FunEmojiLocalizerIndex {
|
||||
const parentKeyToLocaleShortName = new Map<EmojiParentKey, string>();
|
||||
const localeShortNameToParentKey = new Map<string, EmojiParentKey>();
|
||||
@@ -37,10 +38,25 @@ export function createFunEmojiLocalizerIndex(
|
||||
const variantKey = getEmojiVariantKeyByValue(entry.emoji);
|
||||
const parentKey = getEmojiParentKeyByVariantKey(variantKey);
|
||||
const localizedShortName = entry.tags.at(0) ?? entry.shortName;
|
||||
|
||||
parentKeyToLocaleShortName.set(parentKey, localizedShortName);
|
||||
localeShortNameToParentKey.set(localizedShortName, parentKey);
|
||||
}
|
||||
|
||||
if (defaultLocalizerIndex != null) {
|
||||
for (const [
|
||||
parentKey,
|
||||
defaultShortName,
|
||||
] of defaultLocalizerIndex.parentKeyToLocaleShortName) {
|
||||
if (parentKeyToLocaleShortName.has(parentKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
parentKeyToLocaleShortName.set(parentKey, defaultShortName);
|
||||
localeShortNameToParentKey.set(defaultShortName, parentKey);
|
||||
}
|
||||
}
|
||||
|
||||
return { parentKeyToLocaleShortName, localeShortNameToParentKey };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user