fluffychat/.github/instructions/language-list.instructions.md

3.1 KiB

applyTo
lib/pangea/languages/**,lib/pangea/learning_settings/**,lib/pangea/login/pages/language_selection_page.dart

Language List — Client

For the cross-service language list architecture, L1/L2 definitions, and CMS schema, see language-list.instructions.md.

Data Flow

  1. LanguageRepo._fetch() fetches all languages from CMS REST API (/api/languages?limit=500&sort=language_name) — public, no auth
  2. PLanguageStore caches the list in SharedPreferences and re-fetches roughly daily
  3. Hardcoded fallback in LanguageConstants.languageList if CMS is unreachable and cache is empty

L1/L2 Filtering

PLanguageStore exposes three getters:

Getter Filter Used for
baseOptions All languages (no filter) L1 / source / native language selection
targetOptions element.l2 (i.e., l2Support != L2SupportEnum.na) L2 / target / learning language selection
unlocalizedTargetOptions L2 filter + excludes regional variants (e.g., keeps "Portuguese" but not "Portuguese (Brazil)") Course creation language filter

The l2 getter on LanguageModel returns l2Support != L2SupportEnum.na.

Key Usage Sites

Models

  • LanguageModel — core model with langCode, displayName, l2Support, script, localeEmoji, voices
  • L2SupportEnumna, alpha, beta, full with localized display strings and badge rendering
  • LanguageArc — L1→L2 pair, constructed from user settings

Conventions

  • Display names are localized via getDisplayName(context) using l10n keys, with fallback to CMS language_name
  • Regional variants show localeEmoji in place of parenthesized region: "Portuguese 🇧🇷" instead of "Portuguese (Brazil)"
  • langCodeShort strips the territory: en-USen
  • RTL detection uses a hardcoded list in LanguageConstants.rtlLanguageCodes

Future Work

(No linked issues yet.)