mirror of
https://github.com/Lapikud/lapikud.github.io.git
synced 2026-08-09 02:19:13 +00:00
18 lines
490 B
JavaScript
18 lines
490 B
JavaScript
// Helper function to get text with fallback to Estonian
|
|
export function getLangText(item, key, lang = 'est') {
|
|
const value = item[key];
|
|
|
|
// If it's a simple string, return it
|
|
if (typeof value === 'string') {
|
|
return value;
|
|
}
|
|
|
|
// If it's an object with language keys
|
|
if (value && typeof value === 'object') {
|
|
// Try to get the requested language, fallback to Estonian
|
|
return value[lang] || value.est || '';
|
|
}
|
|
|
|
return '';
|
|
}
|