I have encountered an issue with the Babel class in library while setting up internationalization for my FastAPI-based application.
Issue Description:
When the default language is set to "en" (English), attempting to get a localized message by sending the Accept-Language header with "en" returns the key itself instead of the localized message. However, when I set the header Accept-Language to "fr" (French) other than the default, I correctly receive the response in French.
Furthermore, if I set the default language to "fr" and request localization in "fr," the same issue occurs, where the key itself is returned instead of the localized message.
Code Example:
Here's a snippet of my API call for testing using FastAPI:
Hi @Legopapurida ,
I have encountered an issue with the Babel class in library while setting up internationalization for my FastAPI-based application.
Issue Description:
When the default language is set to "en" (English), attempting to get a localized message by sending the Accept-Language header with "en" returns the key itself instead of the localized message. However, when I set the header Accept-Language to "fr" (French) other than the default, I correctly receive the response in French.
Furthermore, if I set the default language to "fr" and request localization in "fr," the same issue occurs, where the key itself is returned instead of the localized message.
Code Example:
Here's a snippet of my API call for testing using FastAPI:
Debugging Findings: Upon debugging the code, I found the following function in the Babel class:
When I removed the condition
if self.default_locale != self.locale
, the localization worked correctly for the default language.Could you please confirm if this is a bug or if I am missing something in my configuration?