php-gettext / Gettext

PHP library to collect and manipulate gettext (.po, .mo, .php, .json, etc)
MIT License
687 stars 134 forks source link

Question: Multiple active Sessions with multiple different Languages. #236

Closed boredom2 closed 4 years ago

boredom2 commented 4 years ago

Hi there,

this is not an Issue, but an important Question came up - sorry, if this Question is already answered somewhere, we couldnt find a definitve Answer yet. If we work with GettextTranslater (so, with .po and .mo) Files - from my Understanding, the appropriate Files will be selected by LC_MESSAGES, which is a System-Wide Constant?

What will happen, if the Server handles 500 Requests with Users in 10 different Languages simultaneously - is it really safe to assume, that each Request returns the Strings in the desired Session Language? If everything is handled by a System Constant, wont this influence the other running Requests then?

And if this is true - what is a better Alternative for this Scenario?

Thanks, Christoph

oscarotero commented 4 years ago

@boredom2 GettextTranslater is just a wrapper of PHP gettext native extension.

The locale configuration for each request is independent, so you can return many different responses in different languages. This is due the way PHP works, in which it creates a new independente thread for each request and destroy it after send the response, so no data is shared between different requests.

boredom2 commented 4 years ago

Thanks for these Insights. I could confirm that in the Meantime I was able to confirm this Behaviour.