Main's new wording (PEP-123 «Продакт» words) kept and wrapped in t()/m();
wording(mode, locale) gives English words for {task}/{runner} placeholders;
glossary check (pnpm lint) passes; English for all new keys (en/merge-*.ts).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
810 B
TypeScript
20 lines
810 B
TypeScript
"use client";
|
|
|
|
import { createContext, useContext, useMemo, type ReactNode } from "react";
|
|
import { wording, type WordMode, type Words } from "@peppa/shared/wording";
|
|
import { useLocale } from "@/components/I18n";
|
|
|
|
const Ctx = createContext<WordMode>("product");
|
|
|
|
/** PEP-123: the layout tells client components which view the user chose («Продакт» / «Инженер»). */
|
|
export function WordsProvider({ mode, children }: { mode: WordMode; children: ReactNode }) {
|
|
return <Ctx.Provider value={mode}>{children}</Ctx.Provider>;
|
|
}
|
|
|
|
/** Words of the current view for client components; server components call `words()` from lib/auth. */
|
|
export function useWords(): Words {
|
|
const mode = useContext(Ctx);
|
|
const locale = useLocale();
|
|
return useMemo(() => wording(mode, locale), [mode, locale]);
|
|
}
|