mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-29 14:37:44 +02:00
* i18n: add japanese locale * fix: spacing issues * refactor * fix(desktop): set <html lang> before paint to avoid JA Kanji font flash Switch the documentElement.lang sync from useEffect to useLayoutEffect so lang is committed before the first paint. Otherwise Japanese desktop users saw one frame of Kanji rendered with the Chinese-first fallback stack before the html[lang|="ja"] CJK override applied. Also fix the stale selector in the HTML_LANG comment (html[lang^="ja"] -> html[lang|="ja"]). Addresses review nits on MUL-2893. Co-authored-by: multica-agent <github@multica.ai> * fix(docs): tokenize the ideographic iteration mark in JA search Add U+3005 (々) to the Japanese search tokenizer character class. It sits just below the kana blocks, so words like 様々 / 日々 / 個々 previously dropped the mark and split awkwardly, hurting recall. Addresses a review nit on MUL-2893. Co-authored-by: multica-agent <github@multica.ai> * fix(i18n): restore ja locale parity after merging main Merging main brought new EN strings into agents/chat/onboarding/settings/ squads that the ja bundle (authored against an older snapshot) lacked, breaking the locales parity test. Add the Japanese translations for the new keys (workspace logo upload, agents runtime filter, chat session-history stop dialog, onboarding social_github, squad archived status) and drop the two renamed chat window keys (active_group / archived_group) that EN removed in favour of history_group. Fixes the failing @multica/views parity.test.ts on the FE CI for MUL-2893. Co-authored-by: multica-agent <github@multica.ai> --------- Co-authored-by: J <j@multica.ai> Co-authored-by: multica-agent <github@multica.ai>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import {
|
|
render,
|
|
type RenderOptions,
|
|
type RenderResult,
|
|
} from "@testing-library/react";
|
|
import { I18nProvider } from "@multica/core/i18n/react";
|
|
import type { ReactElement, ReactNode } from "react";
|
|
import { RESOURCES } from "../locales";
|
|
import type { SupportedLocale } from "@multica/core/i18n";
|
|
|
|
// Single i18n test wrapper for the whole package. Wraps the production
|
|
// `RESOURCES` map (every namespace registered there is available to the
|
|
// component under test) so when a new namespace lands the test never
|
|
// silently renders translation keys-as-text — the test sees the same
|
|
// resource set users do. The previous pattern of inlining a per-file
|
|
// `TEST_RESOURCES` slice meant every test author had to remember to
|
|
// extend the slice when their component started using a new namespace.
|
|
//
|
|
// Use `renderWithI18n` like the standard `render`. Pass `locale: "zh-Hans"`,
|
|
// `locale: "ko"`, or `locale: "ja"` to verify localized strings; default is "en".
|
|
type RenderArgs = Omit<RenderOptions, "wrapper"> & {
|
|
locale?: SupportedLocale;
|
|
};
|
|
|
|
export function renderWithI18n(
|
|
ui: ReactElement,
|
|
options: RenderArgs = {},
|
|
): RenderResult {
|
|
const { locale = "en", ...rest } = options;
|
|
function Wrapper({ children }: { children: ReactNode }) {
|
|
return (
|
|
<I18nProvider locale={locale} resources={RESOURCES}>
|
|
{children}
|
|
</I18nProvider>
|
|
);
|
|
}
|
|
return render(ui, { wrapper: Wrapper, ...rest });
|
|
}
|
|
|
|
export { RESOURCES };
|