Skip to content

Commit

Permalink
Issue #171
Browse files Browse the repository at this point in the history
  • Loading branch information
johnclause committed Jun 2, 2015
1 parent 925fca2 commit cce2778
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 22 deletions.
10 changes: 0 additions & 10 deletions admin/qtx_admin_utils.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
<?php
if ( !defined( 'WP_ADMIN' ) ) exit;

/**
* @since 3.3.1
*/
function qtranxf_error_log($msg) {
global $q_config;
if(isset($q_config['errors'])) $q_config['errors'][] = $msg;
else $q_config['errors'] = array($msg);
error_log('qTranslate-X: '.strip_tags($msg));
}

/**
* Read or enqueue Java script files listed in $jss.
* @since 3.3.2
Expand Down
39 changes: 27 additions & 12 deletions qtranslate_hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,39 @@

/* qTranslate-X Hooks */

/**
* locale for current language and set it on PHP.
*/
function qtranxf_localeForCurrentLanguage($locale){
static $locale_lang;//cache
if(!empty($locale_lang)) return $locale_lang;
global $q_config;
//if( !isset($q_config['language']) ) return $locale;
// try to figure out the correct locale
$windows_locale = qtranxf_default_windows_locale(); //$q_config['windows_locale'];
$lang = $q_config['language'];
$locale_lang=$q_config['locale'][$lang];
$locale = array();
$locale[] = $locale_lang.".utf8";
$locale[] = $locale_lang."@euro";
$locale[] = $locale_lang;
$locale[] = $windows_locale[$lang];
$locale[] = $lang;
$locale_lang = $q_config['locale'][$lang];

// submit a few possible locales
$lc = array();
$lc[] = $locale_lang.'.utf8';
$lc[] = $locale_lang.'@euro';
$lc[] = $locale_lang;
$windows_locale = qtranxf_default_windows_locale();
if(isset($windows_locale[$lang])) $lc[] = $windows_locale[$lang];
$lc[] = $lang;

// return the correct locale and most importantly set it (wordpress doesn't, which is bad)
// only set LC_TIME as everything else doesn't seem to work with windows
setlocale(LC_TIME, $locale);

$loc = setlocale(LC_TIME, $lc);
if(!$loc){
$lc2 = array();
if(strlen($locale_lang) == 2){
$lc2[] = $locale_lang.'_'.strtoupper($locale_lang);
$loc = $locale_lang.'_'.strtoupper($lang); if(!in_array($loc,$lc2)) $lc2[] = $loc;
}
$loc = $lang.'_'.strtoupper($lang); if(!in_array($loc,$lc2)) $lc2[] = $loc;
$loc = setlocale(LC_TIME, $lc2);
//if(!$loc) qtranxf_error_log(sprintf('Could not set locale with setlocale(LC_TIME, %s).', json_encode(array_merge($lc, $lc2))));
}
//qtranxf_dbg_log('qtranxf_localeForCurrentLanguage: $locale='.$locale.'; return: '.$locale_lang.'; Set to ', $loc);
return $locale_lang;
}

Expand Down
10 changes: 10 additions & 0 deletions qtranslate_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ function qtranxf_dbg_echo_if($condition,$msg,$var=null,$bt=false,$exit=false){}
//assert_options(ASSERT_QUIET_EVAL,true);
}// */

/**
* @since 3.3.1
*/
function qtranxf_error_log($msg) {
global $q_config;
if(isset($q_config['errors'])) $q_config['errors'][] = $msg;
else $q_config['errors'] = array($msg);
error_log('qTranslate-X: '.strip_tags($msg));
}

/**
* Default domain translation for strings already translated by WordPress.
* Use of this function prevents xgettext, poedit and other translating parsers from including the string that does not need translation.
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Developers: please drop new topics here, the text will be moved to [qTranslate-X
* Enhancement: 'plugins' vs 'mu-plugins', links of sub-folders, etc. [Issue #168](https://github.com/qTranslate-Team/qtranslate-x/pull/168).
* Enhancement: gettext filters in raw and single language modes.
* Feature: swirly-bracket(brace) language encoding added to be used in places where square-bracket and comment encoding do not work. '[:]' sometimes conflict with shortcodes. '<!--:-->' does not survive tag clean up. '{:}'(swirly-bracket) seems to survive all.
* Fix: handling non-standard language code: [Issue #171](https://github.com/qTranslate-Team/qtranslate-x/issues/171).

### 3.3.5 ###
* Feature: [Integration Framework](https://qtranslatexteam.wordpress.com/integration/) finalizing JSON file format.
Expand Down

0 comments on commit cce2778

Please sign in to comment.