Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Cristiang1021/ErgoKawsay/llms.txt

Use this file to discover all available pages before exploring further.

All user-facing strings in ErgoKawsay live in a single translations.yaml file. A Python generator script converts them to a Dart constant class at lib/core/localization/tr.dart. There are no .arb files, no flutter_gen dependency, and no Flutter intl tooling — just a simple, reviewable plain-text source of truth that non-developers can read and edit.

Supported Locales

CodeLanguage
esSpanish
quKichwa (Quechua)

translations.yaml Structure

Each string is nested under a feature key. The leaf nodes have es and kichwa sub-keys:
modules:
  ergonomics:
    es: "Ergonomía"
    kichwa: "Allillamkayachay"

active_breaks:
  title:
    es: "PAUSAS ACTIVAS"
    kichwa: "Llamkaypi samariy"
  neck_rotation:
    es: "Rotación de cuello"
    kichwa: "Kunkata muyuchiy"
The generator walks the entire tree recursively. When it encounters a node with both es and kichwa keys, it treats that node as a leaf and emits two Dart constants.

Regenerating Translations

1

Edit translations.yaml

Open translations.yaml at the project root. Add a new key under the appropriate feature namespace with both es and kichwa sub-keys, or update an existing string.
2

Install pyyaml

The generator script requires PyYAML. Install it if not already present:
pip install pyyaml
3

Run the generator

From the project root:
python tools/gen_translations.py
4

Use the generated constants

The script overwrites lib/core/localization/tr.dart. New constants are immediately available:
import 'package:ergokawsay/core/localization/tr.dart';

Text(isKichwa ? Tr.modulesErgonomicsQu : Tr.modulesErgonomicsEs)

Using Translations in Code

The generated Tr class exposes every string as a pair of static const String fields — one suffixed Es and one suffixed Qu. A static helper Tr.pick(bool isKichwa, String es, String qu) selects the right string at runtime:
import 'package:ergokawsay/core/localization/tr.dart';

// Direct access
Text(Tr.activeBreaksTitleEs)               // "Pausas Activas"
Text(Tr.activeBreaksTitleQu)               // "Llamkaypi samariy"

// Using the pick helper
Text(Tr.activeBreaksTitle(isKichwa))       // returns the right one

// Using the pick helper directly
Text(Tr.pick(isKichwa, Tr.activeBreaksTitleEs, Tr.activeBreaksTitleQu))

AppLocalizations

AppLocalizations implements LocalizationsDelegate<AppLocalizations> and provides a Flutter-idiomatic API on top of the Tr constants. It reads the current locale from the Locale object passed to it and exposes named string getters:
final loc = AppLocalizations.of(context);
Text(loc.moduleErgonomics)      // "Ergonomía" or "Allillamkayachay"
Text(loc.activeBreaksSubtitle)  // locale-appropriate subtitle
AppLocalizations.delegate is registered in MaterialApp.localizationsDelegates alongside the Flutter standard delegates. The supportedLocales list is [Locale('es'), Locale('qu')]. The class also exposes a welcomeByHour(int hour) helper that returns the appropriate morning / afternoon / evening greeting based on the hour of day.

Kichwa Locale Workaround

Kichwa (qu) is not included in flutter_localizations, so Flutter would throw an error when trying to resolve Material and Widgets strings for that locale. ErgoKawsay works around this with two private custom delegates:
  • _KichwaMaterialDelegate — extends LocalizationsDelegate<MaterialLocalizations> and returns Spanish Material localizations for the qu locale.
  • _KichwaWidgetsDelegate — extends LocalizationsDelegate<WidgetsLocalizations> and returns Spanish Widgets localizations for the qu locale.
These delegates must appear before GlobalMaterialLocalizations.delegate and GlobalWidgetsLocalizations.delegate in the localizationsDelegates list so that they intercept the qu locale first.

LocaleController

LocaleController(StorageService) is a ChangeNotifier that manages the active Locale across the app. It is provided at the root of the widget tree via Provider.
// Switch language at runtime
context.read<LocaleController>().setLocale('qu');  // switch to Kichwa
context.read<LocaleController>().setLocale('es');  // switch to Spanish
setLocale() persists the choice to StorageService, updates the Locale object, and calls notifyListeners(), which triggers a full rebuild of MaterialApp with the new locale.
Always run python tools/gen_translations.py after editing translations.yaml and before building. The Dart constants class is not auto-generated on flutter build or flutter run — you must run the script manually.

Build docs developers (and LLMs) love