load_locale_file

Function load_locale_file 

Source
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 Err when the locale code is empty or has an invalid format
  • Returns Err when the locale file does not exist in the locales directory
  • Returns Err when the locale file cannot be read (I/O error)
  • Returns Err when the locale file is empty
  • Returns Err when 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