Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
achivkin opened this issue May 28, 2024 · 1 comment

Comments

@achivkin
Copy link

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:

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.

@yhuiyang
Copy link

yhuiyang commented Jun 1, 2024

I met similar issue too.
load_directory function choose the wrong translation file due to wrong translation filename is substring matched first.
In my case, when locale is 'zh', it should load 'zh.json', but it loads 'zh-tw.json' instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants