MCPcopy Create free account
hub / github.com/api-platform/website / LanguageProvider

Function LanguageProvider

pwa/contexts/con/LanguageContext.tsx:38–74  ·  view source on GitHub ↗
({
  locale,
  dictionary,
  children,
}: LanguageProviderType)

Source from the content-addressed store, hash-verified

36}
37
38export function LanguageProvider({
39 locale,
40 dictionary,
41 children,
42}: LanguageProviderType) {
43 const translate = t(dictionary);
44
45 const Translate = ({
46 translationKey,
47 translationParams,
48 className,
49 }: {
50 translationKey: string;
51 translationParams?: TranslationPatterns;
52 className?: string;
53 html?: boolean;
54 }) => {
55 return (
56 <div
57 className={className}
58 dangerouslySetInnerHTML={{
59 __html: translate(translationKey, translationParams),
60 }}
61 />
62 );
63 };
64
65 const getLocaleDictionary = () => dictionary;
66
67 return (
68 <LanguageContext.Provider
69 value={{ locale: locale, t: translate, Translate, getLocaleDictionary }}
70 >
71 {children}
72 </LanguageContext.Provider>
73 );
74}

Callers

nothing calls this directly

Calls 1

tFunction · 0.90

Tested by

no test coverage detected