问题
I asked this question on serverfault but I didn't get any response. I try here...
I developped a site on my web server at home.
When I modify the translation files, I have to restart the web server Apache.
/etc/init.d/httpd graceful
Easy...
Suppose that my site is hosted on shared host.
Suppose now I need to modify the translation files.
I can't restart the server...
How do you use gettext
in this context?
Are you allow to restart the server with the option graceful only?
Does the share host restart the server once a day to resolve this kind of problem?
How do you work with such constraints?
回答1:
the post here on the gettext function has some information for making gettext work without restarting apache:
http://www.php.net/manual/en/function.gettext.php#58310
回答2:
call clearstatcache();
after making translation from *.po
to *.mo
回答3:
You can rename your *.mo file and your gettext domain to flush gettext cache without restarting apache server.But in production environment,it's unsuitable.
回答4:
There is no other solution than to brutally force a cache miss for each and every *.mo file every time one of them changes. Change a single string? New cache era!
I do this by writing middleware that copies all *.mo files to a timestamp-named directory (the timestamp being that of the newest *.mo file) and updates the application config with the new message path - if the newest timestamp actually changed, that is. Thus textdomains are now loaded from completely different paths, and this is what finally manages to kill the stupid gettext cache stinking dead.
来源:https://stackoverflow.com/questions/2177895/how-do-you-use-gettext-on-server-apache-you-can-t-restart