You are here

function og_set_locale in Organic groups 5.3

Same name and namespace in other branches
  1. 5.8 og.module \og_set_locale()
  2. 5 og.module \og_set_locale()
  3. 5.2 og.module \og_set_locale()
  4. 5.7 og.module \og_set_locale()

Like locale_initialize(), but includes a check for group language and sets accordingly. Priority goes: user => group => site default

1 call to og_set_locale()
og_init in ./og.module
This processing cannot happen later in the request because

File

./og.module, line 176

Code

function og_set_locale() {
  global $user, $locale;
  if (function_exists('locale')) {
    $languages = locale_supported_languages();
    $languages = $languages['name'];
  }
  else {

    // Ensure the locale/language is correctly returned, even without locale.module.
    // Useful for e.g. XML/HTML 'lang' attributes.
    $languages = array(
      'en' => 'English',
    );
  }
  if ($user->uid && isset($languages[$user->language])) {

    // do nothing. user specified language has priority
  }
  elseif ($group_node = og_get_group_context()) {
    if ($group_node->og_language && isset($languages[$group_node->og_language])) {
      $locale = $group_node->og_language;
    }
  }
}