MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / getTranslationEntry

Function getTranslationEntry

curriculum/src/build-curriculum.ts:77–90  ·  view source on GitHub ↗
(
  dicts: Record<string, Record<string, unknown>>,
  { engId, text }: { engId: string; text: string }
)

Source from the content-addressed store, hash-verified

75 * @returns {Object} Object mapping language codes to translated text or fallback English text
76 */
77export function getTranslationEntry(
78 dicts: Record<string, Record<string, unknown>>,
79 { engId, text }: { engId: string; text: string }
80) {
81 return Object.keys(dicts).reduce((acc, lang) => {
82 const entry = dicts[lang]?.[engId];
83 if (entry) {
84 return { ...acc, [lang]: entry };
85 } else {
86 // default to english
87 return { ...acc, [lang]: text };
88 }
89 }, {});
90}
91
92/**
93 * Creates a mapping of English comments to their translations across all supported languages

Callers 1

createCommentMapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected