Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Last active August 29, 2015 14:14
Show Gist options
  • Save hellofromtonya/b2643b0bd6365ebc23cb to your computer and use it in GitHub Desktop.
Save hellofromtonya/b2643b0bd6365ebc23cb to your computer and use it in GitHub Desktop.
force $locale when WPLANG is 'fr_FR' to set translation files to -fr.mo
# ------------------------------------------------------------------
# sp_localisation()
# Setup the forum localisation
# ------------------------------------------------------------------
function sp_localisation() {
# i18n support
global $spPaths;
$locale = get_locale();
//* ADDED by TONYA 01.23.2015
if ('fr_FR' == $locale) $locale = 'fr';
$bothSpecial = apply_filters('sph_load_both_textdomain', array('sp_ahah=permissions'));
$adminSpecial = apply_filters('sph_load_admin_textdomain', array('&loadform', 'sp_ahah=help', 'sp_ahah=multiselect', 'sp_ahah=integration-perm', 'sp_ahah=components', 'sp_ahah=forums', 'sp_ahah=profiles', 'sp_ahah=users', 'sp_ahah=usergroups'));
if (sp_strpos_arr($_SERVER['QUERY_STRING'], $bothSpecial) !== false) {
$mofile = WP_CONTENT_DIR.'/'.$spPaths['language-sp'].'/spa-'.$locale.'.mo';
load_textdomain('spa', $mofile);
$mofile = WP_CONTENT_DIR.'/'.$spPaths['language-sp'].'/sp-'.$locale.'.mo';
$mofile = apply_filters('sph_localization_mo', $mofile);
load_textdomain('sp', $mofile);
} else if (is_admin() || sp_strpos_arr($_SERVER['QUERY_STRING'], $adminSpecial) !== false) {
$mofile = WP_CONTENT_DIR.'/'.$spPaths['language-sp'].'/spa-'.$locale.'.mo';
load_textdomain('spa', $mofile);
} else {
$mofile = WP_CONTENT_DIR.'/'.$spPaths['language-sp'].'/sp-'.$locale.'.mo';
$mofile = apply_filters('sph_localization_mo', $mofile);
load_textdomain('sp', $mofile);
}
}
function sp_plugin_localisation($domain) {
global $spPaths;
$locale = get_locale();
//* ADDED by TONYA 01.23.2015
if ('fr_FR' == $locale) $locale = 'fr';
$mofile = WP_CONTENT_DIR.'/'.$spPaths['language-sp-plugins'].'/'.$domain.'-'.$locale.'.mo';
$mofile = apply_filters('sph_localization_plugin_mo', $mofile, $domain);
load_textdomain($domain, $mofile);
}
function sp_theme_localisation($domain) {
global $spPaths, $spGlobals;
$locale = get_locale();
//* ADDED by TONYA 01.23.2015
if ('fr_FR' == $locale) $locale = 'fr';
$mofile = WP_CONTENT_DIR.'/'.$spPaths['language-sp-themes'].'/'.$domain.'-'.$locale.'.mo';
$mofile = apply_filters('sph_localization_theme_mo', $mofile, $domain);
load_textdomain($domain, $mofile);
$spGlobals['themedomain'] = $domain;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment