danhper / danhper/python-i18n

I18nFileLoadError for locales ‘am’ and ‘ml’ due to Misidentification in load_directory

Open
#43 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
246
Forks
46
PR merge metrics
No merged PRs in 30d

Description

### Body
Hello,

When the user's locale is set to 'am' or 'ml', the code in the `load_directory` function of `resource_loader.py` incorrectly assumes that a corresponding localization file exists. This leads to an `i18n.loaders.loader.I18nFileLoadError`. The error message displayed is:

```plaintext
I18nFileLoadError: error getting data from resources/translations/de.yaml: ml not defined
```

This issue arises due to improper file existence checking. The locales 'ml' and 'am' are mistakenly identified as existing because they are substrings of the ".yaml" file extension. This results in the erroneous assumption that the relevant localization files are present.

#### Suggested Fix
A more robust method of checking for the existence of localization files should be implemented to prevent substring matches within file extensions.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.