i18n System

How BodyMetrics manages multilingual translations — catalog, adapter, fallback, and validator.

Architecture

The localization system has three components with a clear separation of concerns:

ComponentFileRole
Catalogsource/i18n/BodyMetricsLocaleCatalog.mcStores all translations for all languages
Adaptersource/BodyMetricsLocale.mcSingle public interface for runtime string lookup
Validatorsource/i18n/BodyMetricsLocaleValidator.mcDevelopment-time completeness checker

Catalog Structure

BodyMetricsLocaleCatalog.mc stores every translatable string as a key/value pair, grouped by language. English is the reference language: every key present in English must also be present in all other languages.

// Pseudocode  actual implementation uses Dictionary literals
var catalog = {
    "en" => { "summary.weight" => "Weight", "summary.fat" => "Body Fat",  },
    "it" => { "summary.weight" => "Peso",   "summary.fat" => "Grasso corporeo",  },
    "fr" => { "summary.weight" => "Poids",  "summary.fat" => "Masse grasse",  },
    "es" => { "summary.weight" => "Peso",   "summary.fat" => "Grasa corporal",  }
};

Adapter — BodyMetricsLocale

BodyMetricsLocale.mc is the only component the rest of the app should call for string lookups. The interface is a single function:

BodyMetricsLocale.get(key)   // returns the localized string

Internally it reads the current language setting and delegates to the catalog.

Fallback Chain

When a key is requested, the adapter resolves it in order:

1. Active language  →  found? return
2. English ("en")   →  found? return (+ log warning in dev builds)
3. Raw key          →  return as-is  (visible only in bugs)

In production, all four languages are complete, so the fallback path is never reached.

Adding a New String

  1. Add the key to the English catalog entry in BodyMetricsLocaleCatalog.mc.
  2. Add the corresponding translation for all four languages (it, fr, es).
  3. Run the locale validator (Debug menu → Locale Validator) to confirm completeness.

Locale Validator

BodyMetricsLocaleValidator.mc compares every catalog key in every non-English language against the English reference. Any missing or empty entry is reported as a validation failure.

The validator is accessible at runtime from Debug menu → Locale Validator in development builds. It is not present in production builds.

Language Setting Persistence

The selected language is persisted in the app’s local storage. It survives:

  • App restarts
  • Watch sleep / wake
  • Full data reset (the language preference is preserved)

Supported Language Codes

CodeLanguageGarmin Locale Code
enEnglisheng
itItalianita
frFrenchfre
esSpanishspa

See Also