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

Is starlette-i18n limited to provide only one extra locale? #15

Closed
boamaod opened this issue Jan 19, 2022 · 3 comments
Closed

Is starlette-i18n limited to provide only one extra locale? #15

boamaod opened this issue Jan 19, 2022 · 3 comments

Comments

@boamaod
Copy link

boamaod commented Jan 19, 2022

Do I understand correctly that starlette-i18n cannot provide more than one translation locale at a time? Examples here also deliver only one extra locale besides English as the default language. Is that intentional and expresses a limitation of using starlette-i18n and more generally jinja2.ext.i18n for ASGI frameworks like Starlette?

I found related discussions at encode/starlette#279 (comment) and pallets/jinja#1323 (comment), but maybe you @bigbag as the author of this localisation helper have further comments and maybe some practical suggestions on this?

@bigbag
Copy link
Owner

bigbag commented Feb 6, 2022

Hi. yes, it is correct one translation locale by one request. I do not know examples as you need more one locale for request
For example user one with locale CN and user two with DE makes two request with different locales and every user get response with correct locale.

@bigbag
Copy link
Owner

bigbag commented Feb 6, 2022

Examples here also deliver only one extra locale besides English as the default language.

It is only example. You can use so many locales as you need. For example we use this library with 10 different locales.

@boamaod
Copy link
Author

boamaod commented Feb 6, 2022

It is only example. You can use so many locales as you need. For example we use this library with 10 different locales.

And users haven't reported translations being slightly mixed up or performance issues in cases of high load of the website?

I found related discussions at encode/starlette#279 (comment) and pallets/jinja#1323 (comment), but maybe you @bigbag as the author of this localisation helper have further comments and maybe some practical suggestions on this?

In first discussion I referred Starlette developers seem to agree that Jinja2 i18n extension is not suitable for ASGI, because it uses global language state. In the second discussion the same point of using global gettext instead of isolated context for each locale is made in Jinja2 issue tracker referring to Aiohttp. How have you overcome this issue of Jinja i18n extension using global gettext functions, @bigbag? Since starlette-i18n seems to provide a wrapper for Jinja2 i18n extension, it has to handle these problems somehow, doesn't it?

@bigbag bigbag closed this as completed Jan 19, 2023
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