All files / src/utils languages.ts

100% Statements 11/11
100% Branches 12/12
100% Functions 4/4
100% Lines 9/9

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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72                              9x                   9x                                           821x 1381x             5x 5x                     15x 15x 14x    
/**
 * Language configuration for Flows application
 */
 
export interface LanguageInfo {
  code: string
  name: string
  nativeName: string
  flag: string
}
 
/**
 * UI Languages - Languages available for the Flows interface itself
 * Currently: English and French only
 */
export const UI_LANGUAGES: LanguageInfo[] = [
  { code: 'en', name: 'English', nativeName: 'English', flag: '🇬🇧' },
  { code: 'fr', name: 'French', nativeName: 'Français', flag: '🇫🇷' }
]
 
/**
 * Content Languages - Languages available for user-generated content
 * (flows, entities, roles, items, etc.)
 * Much broader selection to support international users
 */
export const CONTENT_LANGUAGES: LanguageInfo[] = [
  { code: 'en', name: 'English', nativeName: 'English', flag: '🇬🇧' },
  { code: 'fr', name: 'French', nativeName: 'Français', flag: '🇫🇷' },
  { code: 'es', name: 'Spanish', nativeName: 'Español', flag: '🇪🇸' },
  { code: 'de', name: 'German', nativeName: 'Deutsch', flag: '🇩🇪' },
  { code: 'it', name: 'Italian', nativeName: 'Italiano', flag: '🇮🇹' },
  { code: 'pt', name: 'Portuguese', nativeName: 'Português', flag: '🇵🇹' },
  { code: 'nl', name: 'Dutch', nativeName: 'Nederlands', flag: '🇳🇱' },
  { code: 'pl', name: 'Polish', nativeName: 'Polski', flag: '🇵🇱' },
  { code: 'ru', name: 'Russian', nativeName: 'Русский', flag: '🇷🇺' },
  { code: 'ja', name: 'Japanese', nativeName: '日本語', flag: '🇯🇵' },
  { code: 'zh', name: 'Chinese', nativeName: '中文', flag: '🇨🇳' },
  { code: 'ar', name: 'Arabic', nativeName: 'العربية', flag: '🇸🇦' }
]
 
/**
 * Get language info by code
 */
export function getLanguageInfo(
  code: string,
  type: 'ui' | 'content' = 'content'
): LanguageInfo | undefined {
  const languages = type === 'ui' ? UI_LANGUAGES : CONTENT_LANGUAGES
  return languages.find((lang) => lang.code === code)
}
 
/**
 * Get flag emoji for language code
 */
export function getLanguageFlag(code: string, type: 'ui' | 'content' = 'content'): string {
  const info = getLanguageInfo(code, type)
  return info?.flag || code.toUpperCase()
}
 
/**
 * Get language name (in English or native)
 */
export function getLanguageName(
  code: string,
  native = false,
  type: 'ui' | 'content' = 'content'
): string {
  const info = getLanguageInfo(code, type)
  if (!info) return code
  return native ? info.nativeName : info.name
}