mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 16:39:39 +02:00
Projects included: - maerchenzauber (NestJS backend + Expo mobile + SvelteKit web + Astro landing) - manacore (Expo mobile + SvelteKit web + Astro landing) - manadeck (NestJS backend + Expo mobile + SvelteKit web) - memoro (Expo mobile + SvelteKit web + Astro landing) This commit preserves the current state before monorepo restructuring. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
25 lines
No EOL
981 B
TypeScript
25 lines
No EOL
981 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})`;
|
|
} |