MCPcopy
hub / github.com/GitbookIO/gitbook / getSpaceLanguage

Function getSpaceLanguage

packages/gitbook/src/intl/server.ts:38–54  ·  view source on GitHub ↗
(context: GitBookAnyContext)

Source from the content-addressed store, hash-verified

36 * Create the translation context for a space to use in the server components.
37 */
38export function getSpaceLanguage(context: GitBookAnyContext): TranslationLanguage {
39 const fallback = languages[DEFAULT_LOCALE];
40
41 const locale = getSpaceLocale(context);
42
43 let language = fallback;
44 // @ts-ignore
45 if (locale !== DEFAULT_LOCALE && languages[locale]) {
46 // @ts-ignore
47 language = languages[locale];
48 }
49
50 return {
51 ...fallback,
52 ...language,
53 };
54}
55
56function checkIsValidLocale(locale: string): locale is TranslationLocale {
57 return locale in languages;

Callers 14

SpaceLayoutFunction · 0.90
PageAsideHeaderFunction · 0.90
PageFooterNavigationFunction · 0.90
PageBodyFunction · 0.90
CustomizationRootLayoutFunction · 0.90
HintFunction · 0.90
InlineLinkFunction · 0.90
PDFPageFunction · 0.90

Calls 1

getSpaceLocaleFunction · 0.85

Tested by

no test coverage detected