| 75 | * @returns {Object} Object mapping language codes to translated text or fallback English text |
| 76 | */ |
| 77 | export 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 |