bb_get_locale

Gets the current locale.

Description

(string) bb_get_locale(); 

If the locale is set, then it will filter the locale in the locale filter hook and return the value.

If the locale is not set already, then the BB_LANG constant is used if it is defined. Then it is filtered through the locale filter hook and the value for the locale global set and the locale is returned.

The process to get the locale should only be done once but the locale will always be filtered using the locale hook.

Returns (string)

The locale of the blog or from the 'locale' hook.


Usage

  1. if ( !function_exists( 'bb_get_locale' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/functions.bb-l10n.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = bb_get_locale(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-includes/functions.bb-l10n.php  
  1. function bb_get_locale() { 
  2. global $locale; 
  3.  
  4. if (isset($locale)) 
  5. return apply_filters( 'locale', $locale ); 
  6.  
  7. // BB_LANG is defined in bb-config.php 
  8. if (defined('BB_LANG')) 
  9. $locale = BB_LANG
  10.  
  11. if (empty($locale)) 
  12. $locale = 'en_US'; 
  13.  
  14. return apply_filters('locale', $locale);