How to clear php's gettext cache without restart Apache nor change domain?

前端 未结 6 1533
别跟我提以往
别跟我提以往 2020-12-03 07:34

This is a little code snippet from php manual:

putenv(\'LC_ALL=zh_CN\');
setlocale(LC_ALL, \'zh_CN\');

bindtextdomain(\'domain\', \'./locale\');
textdomain(         


        
6条回答
  •  北海茫月
    2020-12-03 07:51

    The solution for me was to save the files with a different name, using the date for example, and then changing the domain:

    #the path for a domain, the .mo files must match the domain
    #the trick to avoid permanent caching, is to use different names for the domain,             like the date messages_180320151250
    $domain = 'messages_180320151300';
    
    #sets the path for a domain, the .mo files must match the domain
    bindtextdomain($domain, $_SERVER['DOCUMENT_ROOT']."/apps/cp/locale");
    
    textdomain($domain);
    

提交回复
热议问题