managarten/apps/memoro/apps/mobile/utils/languageDisplay.ts
Till JS d8a2b37126 chore(memoro): import legacy backend, mobile, and landing apps
Adds the original NestJS backends (backend, audio-backend), Expo mobile app,
and Astro landing page as-is from the standalone memoro repo. These are
not yet migrated to monorepo standards (migration tracked in memory/CLAUDE.md).

Also adds eslint.config.mjs ignore for apps/*/apps/audio-backend/**
and .prettierignore entries for legacy memoro dirs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 17:30:00 +02:00

25 lines
966 B
TypeScript

import { TFunction } from 'react-i18next';
/**
* Formats language name for display showing frontend language name first, followed by native name
* @param languageCode - The language code (e.g., 'de', 'en', 'fr')
* @param nativeName - The native name of the language (e.g., 'Deutsch', 'English', 'Français')
* @param t - Translation function from useTranslation hook
* @returns Formatted language string (e.g., "German (Deutsch)" when interface is English)
*/
export function formatLanguageDisplay(
languageCode: string,
nativeName: string,
t: TFunction
): string {
// Get the translated language name in the current frontend language
const translatedName = t(`language.languages.${languageCode}`, nativeName);
// If the translated name is the same as native name, just return the native name
if (translatedName === nativeName) {
return nativeName;
}
// Return format: "TranslatedName (NativeName)"
return `${translatedName} (${nativeName})`;
}