All files / src/locales recipeTagLabels.ts

100% Statements 6/6
100% Branches 4/4
100% Functions 3/3
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26            1x         1x         1176x     1056x       120x    
// Localized labels for the recipe tag taxonomy (src/recipeTags.json).
// English labels live in the taxonomy itself and act as the fallback.
 
import { recipeFacetLabelsDe, recipeTagLabelsDe } from './recipeTagsDe'
import { recipeFacetLabelsHu, recipeTagLabelsHu } from './recipeTagsHu'
 
const tagLabels: Record<string, Record<string, string>> = {
	DE: recipeTagLabelsDe,
	HU: recipeTagLabelsHu,
}
 
const facetLabels: Record<string, Record<string, string>> = {
	DE: recipeFacetLabelsDe,
	HU: recipeFacetLabelsHu,
}
 
const baseLanguage = (lang: string) => lang.toUpperCase().split('-')[0]
 
export function localizeTagLabel(id: string, fallback: string, lang: string): string {
	return tagLabels[baseLanguage(lang)]?.[id] ?? fallback
}
 
export function localizeFacetLabel(id: string, fallback: string, lang: string): string {
	return facetLabels[baseLanguage(lang)]?.[id] ?? fallback
}