[wp-hackers] Multilanguage: how to redefine locale on the fly

Manuel Schmalstieg webdev at ms-studio.net
Wed Mar 6 13:11:16 UTC 2013


Alright, that's what I thought, thanks for confirming.

However, when I try this in a template file:

global $locale;
$locale = "de_DE";

...on a site which by default is in French, this doesn't have any
effect on the output of the date_i18n() function - it will still
generate all the days and months in French.

If I try using a filter in functions.php:

function nfo_redefine_locale($locale) {
  global $locale;
  $locale = 'de_DE';
  return $locale;
}
add_filter('locale','nfo_redefine_locale');

...it still doesn't switch the output to German.

Very mysterious :-/


Otto <otto at ottodestruct.com> wrote:
> Don't try to change WPLANG, you can't change a define'd constant.
>
> Instead, change the global $locale, or put a filter on 'locale'.
>


More information about the wp-hackers mailing list