Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
feat(web): name Reactions in the language on screen
Kilyna8b4d73659ff
diff --git a/apps/web/src/features/rooms/chat/message-reactions/message-reaction-bar.tsx b/apps/web/src/features/rooms/chat/message-reactions/message-reaction-bar.tsxindex b163bdfb..1e71e35e 100644--- a/apps/web/src/features/rooms/chat/message-reactions/message-reaction-bar.tsx+++ b/apps/web/src/features/rooms/chat/message-reactions/message-reaction-bar.tsx@@ -6,11 +6,11 @@ import type {TeamHubMessageReactionId,} from "@/features/teamhub/teamhub-types";import { commonMessages } from "@/i18n/common.messages";-import { useT } from "@/i18n/use-translation";+import { useTranslation } from "@/i18n/use-translation";import { chatMessages } from "../chat.messages";-import { useReactionCatalog } from "./reaction-catalog";+import { reactionName, useReactionCatalog } from "./reaction-catalog";import { animateTransform, animationsEnabled } from "./reaction-motion";/**@@ -35,7 +35,7 @@ export function MessageReactionBar({message: TeamHubMessage;onToggle?: (reactionId: TeamHubMessageReactionId) => void;}) {- const t = useT();+ const { language, t } = useTranslation();const catalog = useReactionCatalog();const reactions = catalog ? (message.reactions ?? []) : [];const rowRef = useRef<HTMLDivElement>(null);@@ -125,7 +125,7 @@ export function MessageReactionBar({<buttonaria-label={t(chatMessages.reactionSummary, {count,- emoji: entry.name,+ emoji: reactionName(entry, language),names: reactors,})}aria-pressed={own}diff --git a/apps/web/src/features/rooms/chat/message-reactions/message-reaction-picker.tsx b/apps/web/src/features/rooms/chat/message-reactions/message-reaction-picker.tsxindex 77ac83e4..d1a7d90e 100644--- a/apps/web/src/features/rooms/chat/message-reactions/message-reaction-picker.tsx+++ b/apps/web/src/features/rooms/chat/message-reactions/message-reaction-picker.tsx@@ -24,13 +24,14 @@ import { createPortal } from "react-dom";import { Icon, type IconSvgElement } from "@/components/ui/icon";import { Spinner } from "@/components/ui/spinner";import type { TeamHubMessageReactionId } from "@/features/teamhub/teamhub-types";-import { useT } from "@/i18n/use-translation";+import { useTranslation } from "@/i18n/use-translation";import { chatMessages } from "../chat.messages";import {reactionCategoryLabel,type ReactionCatalogEntry,+ reactionName,searchReactionCatalog,useReactionCatalog,} from "./reaction-catalog";@@ -94,7 +95,7 @@ export function MessageReactionPicker({onClose: () => void;onSelect: (id: TeamHubMessageReactionId) => void;}) {- const t = useT();+ const { language, t } = useTranslation();const catalog = useReactionCatalog();const [expanded, setExpanded] = useState(false);const [query, setQuery] = useState("");@@ -354,11 +355,11 @@ export function MessageReactionPicker({<>{quick.map((entry) => (<button- aria-label={entry.name}+ aria-label={reactionName(entry, language)}className="flex size-9 items-center justify-center rounded-full text-[22px] leading-none hover:bg-accent focus-visible:outline-2 focus-visible:outline-app-focus"key={entry.id}onClick={() => pick(entry)}- title={entry.name}+ title={reactionName(entry, language)}type="button">{entry.glyph}@@ -478,7 +479,7 @@ export function MessageReactionPicker({const isActive = flatIndex === activeIndex;return (<button- aria-label={entry.name}+ aria-label={reactionName(entry, language)}aria-selected={isActive}className={`flex size-10 items-center justify-center rounded-md text-[22px] leading-none hover:bg-accent ${isActive ? "bg-accent" : ""@@ -489,7 +490,7 @@ export function MessageReactionPicker({onMouseEnter={() => setActiveIndex(flatIndex)}role="option"tabIndex={-1}- title={entry.name}+ title={reactionName(entry, language)}type="button">{entry.glyph}diff --git a/apps/web/src/features/rooms/chat/message-reactions/message-reactions.test.tsx b/apps/web/src/features/rooms/chat/message-reactions/message-reactions.test.tsxindex bcc5a00f..de02f2f7 100644--- a/apps/web/src/features/rooms/chat/message-reactions/message-reactions.test.tsx+++ b/apps/web/src/features/rooms/chat/message-reactions/message-reactions.test.tsx@@ -43,6 +43,7 @@ import emojiData from "@emoji-mart/data/sets/15/native.json";import {buildReactionCatalog,reactionCategoryLabel,+ reactionName,searchReactionCatalog,} from "./reaction-catalog";import {@@ -184,6 +185,17 @@ describe("Reaction state", () => {).toEqual(["heart"]);});+ it("names a Reaction from the annotation only in its language", () => {+ const catalog = buildReactionCatalog(emojiData, [+ { hexcode: "1F44C", label: "annotated ok" },+ ]);+ const annotated = catalog.byId.get("ok_hand")!;+ const plain = catalog.byId.get("tada")!;+ expect(reactionName(annotated, "en")).toBe("Ok Hand");+ expect(reactionName(annotated, "zh-CN")).toBe("annotated ok");+ expect(reactionName(plain, "zh-CN")).toBe("Party Popper");+ });+it("supports only ordinary chat Messages", () => {expect(messageSupportsReactions(message())).toBe(true);expect(diff --git a/apps/web/src/features/rooms/chat/message-reactions/reaction-catalog.ts b/apps/web/src/features/rooms/chat/message-reactions/reaction-catalog.tsindex e2d06f7f..69e0ffb6 100644--- a/apps/web/src/features/rooms/chat/message-reactions/reaction-catalog.ts+++ b/apps/web/src/features/rooms/chat/message-reactions/reaction-catalog.ts@@ -1,6 +1,6 @@import { useEffect, useState } from "react";-import type { Translate } from "@/i18n/language";+import type { Language, Translate } from "@/i18n/language";import type { Message } from "@/i18n/messages";import { chatMessages } from "../chat.messages";@@ -31,6 +31,8 @@ export interface ReactionCatalogEntry {readonly id: string;readonly glyph: string;readonly name: string;+ /** The CLDR name in the annotation language, when the set has one. */+ readonly annotationName?: string;readonly keywords: readonly string[];}@@ -76,10 +78,19 @@ export function reactionCategoryLabel(categoryId: string, t: Translate) {}// The emoji-mart dataset is English-only; CLDR Chinese annotations let-// Chinese-speaking users search Reactions too. The path stays a literal so the-// bundler emits one lazy chunk instead of one per emojibase locale.+// Chinese-speaking users search Reactions too and name them in Chinese. The+// path stays a literal so the bundler emits one lazy chunk instead of one per+// emojibase locale.const loadReactionAnnotationLocale = () =>import("emojibase-data/zh/compact.json");+const ANNOTATION_LANGUAGE: Language = "zh-CN";++/** A Reaction's name in the language on screen; English without an annotation. */+export function reactionName(entry: ReactionCatalogEntry, language: Language) {+ return language === ANNOTATION_LANGUAGE && entry.annotationName+ ? entry.annotationName+ : entry.name;+}// Both datasets spell the same code point sequence, but only emoji-mart keeps// the FE0F variation selector and uses lowercase hex.@@ -114,6 +125,7 @@ export function buildReactionCatalog(id,glyph,name: emoji.name,+ ...(annotation?.label ? { annotationName: annotation.label } : {}),keywords: [...new Set([...emoji.keywords,