pub fn load_locale_file(
locale: &str,
locales_dir: &Path,
) -> Result<TranslationMap, String>Expand description
What: Load a locale YAML file and parse it into a TranslationMap.
Inputs:
locale: Locale code (e.g., “de-DE”)locales_dir: Path to locales directory
Output:
Result<TranslationMap, String>containing translations or error
§Errors
- Returns
Errwhen the locale code is empty or has an invalid format - Returns
Errwhen the locale file does not exist in the locales directory - Returns
Errwhen the locale file cannot be read (I/O error) - Returns
Errwhen the locale file is empty - Returns
Errwhen the YAML content cannot be parsed
Details:
- Loads file from
locales_dir/{locale}.yml - Parses YAML structure into nested
HashMap - Returns error if file not found or invalid YAML
- Validates locale format before attempting to load