Exemplo n.º 1
0
function qtranxf_test_dt_format($cfg, $cfg_name = 'dtf', $format = 'F j, Y')
{
    global $q_config;
    $q_config['locale'] = array_merge(qtranxf_default_locale(), $q_config['locale']);
    $enabled_languages = $q_config['enabled_languages'];
    require_once QTRANSLATE_DIR . '/admin/qtx_admin_options_update.php';
    $t = strtotime('Nov 16, 2014 3:04pm');
    //qtranxf_dbg_log('qtranxf_test_dt_format: $t: ',$t);
    $m = PHP_EOL;
    foreach ($cfg as $c => $f) {
        if (!in_array($c, $q_config['enabled_languages'])) {
            $q_config['enabled_languages'][] = $c;
        }
        qtranxf_updateGettextDatabases(true, $c);
        $d = qtranxf_translate_dt_format($format, $c);
        //$d = qtranxf_convert_strftime2date($f);
        $sd = date($d, $t);
        $m .= '$' . $cfg_name . '[\'' . $c . '\'] = \'' . $d . '\';// "' . $sd . '"';
        if (false) {
            require_once QTRANSLATE_DIR . '/inc/qtx_date_time.php';
            $ff = qtranxf_convertDateFormatToStrftimeFormat($f);
            $sf = qtranxf_strftime($ff, $t);
            $m .= ' // strftime("' . $f . '") "' . ($sf ? $sf : 'invalid') . '"';
        }
        $m .= PHP_EOL;
    }
    $q_config['enabled_languages'] = $enabled_languages;
    //qtranxf_dbg_log('qtranxf_test_dt_format("'.$cfg_name.'","'.$format.'"): $m:'.$m);
    return $m;
}
Exemplo n.º 2
0
/**
 * since 3.2.9.2
 */
function qtranxf_default_enabled_languages()
{
    //$locale = defined('WPLANG') ? WPLANG : get_option('WPLANG','en_US');
    $locale = get_locale();
    if (!$locale) {
        $locale = 'en_US';
    }
    $lang = null;
    $locales = qtranxf_default_locale();
    foreach ($locales as $ln => $lo) {
        if ($lo != $locale) {
            continue;
        }
        $lang = $ln;
        break;
    }
    if (!$lang) {
        $lang = substr($locale, 0, 2);
    }
    if (!qtranxf_language_predefined($lang)) {
        $langs = array();
        $langs['language_name'][$lang] = 'Unknown';
        $langs['flag'][$lang] = 'us.png';
        $langs['locale'][$lang] = $locale;
        $langs['date_format'][$lang] = '%A %B %e%q, %Y';
        $langs['time_format'][$lang] = '%I:%M %p';
        $langs['not_available'][$lang] = 'Sorry, this entry is only available in %LANG:, : and %.';
        qtranxf_save_languages($langs);
    }
    //qtranxf_dbg_log('qtranxf_default_enabled_languages: $lang='.$lang.' $locale:',$locale);
    return array($lang, $lang != 'en' ? 'en' : 'de');
    //return array( 'de', 'en', 'zh' );
}
Exemplo n.º 3
0
/**
 * since 3.2.9.2
 */
function qtranxf_default_enabled_languages()
{
    //$languages = get_available_languages();
    //qtranxf_dbg_log('qtranxf_default_enabled_languages: count(languages): ',count($languages));
    //qtranxf_dbg_log('qtranxf_default_enabled_languages: get_available_languages: ',$languages);
    $locale = get_locale();
    if (!$locale) {
        $locale = 'en_US';
    }
    $lang = null;
    $locales = qtranxf_default_locale();
    foreach ($locales as $ln => $lo) {
        if ($lo != $locale) {
            continue;
        }
        $lang = $ln;
        break;
    }
    if (!$lang) {
        require_once ABSPATH . 'wp-admin/includes/translation-install.php';
        $translations = wp_get_available_translations();
        //qtranxf_dbg_log('qtranxf_default_enabled_languages: count(available_translations): ',count($translations));
        //qtranxf_dbg_log('qtranxf_default_enabled_languages: wp_get_available_translations: ',$translations);
        if (empty($translations[$locale])) {
            $lang = substr($locale, 0, 2);
            $name = 'Unknown';
        } else {
            $translation = $translations[$locale];
            $lang = current($translation['iso']);
            if (!$lang) {
                $lang = substr($locale, 0, 2);
            }
            $name = empty($translation['native_name']) ? 'Unknown' : $translation['native_name'];
        }
        $flag_location = WP_CONTENT_DIR . '/' . qtranxf_flag_location_default();
        do {
            $p = strpos($locale, '_');
            if ($p > 0) {
                $fn = strtolower(substr($locale, $p, 2));
                $flag = $fn . '.png';
                if (file_exists($flag_location . $flag)) {
                    break;
                }
                $flag = $fn . '.gpg';
                if (file_exists($flag_location . $flag)) {
                    break;
                }
            }
            $fn = strtolower(substr($locale, 0, 2));
            $flag = $fn . '.png';
            if (file_exists($flag_location . $flag)) {
                break;
            }
            $flag = $fn . '.gpg';
            if (file_exists($flag_location . $flag)) {
                break;
            }
            $flag = 'aa.png';
        } while (false);
        $props = array('language_name' => $name, 'flag' => $flag, 'locale' => $locale, 'date_format' => __('F j, Y'), 'time_format' => __('g:i a'), 'not_available' => 'Sorry, this entry is only available in %LANG:, : and %.');
        qtranxf_set_default_options($qtranslate_options);
        qtranxf_save_languages(array($lang => $props), $qtranslate_options);
        //qtranxf_dbg_log('qtranxf_default_enabled_languages: $props: ',$props);
    }
    $enabled_languages = array($lang);
    if ($lang != 'en') {
        $enabled_languages[] = 'en';
    }
    //qtranxf_dbg_log('qtranxf_default_enabled_languages: $lang="'.$lang.'"; $locale="'.$locale.'"; $enabled_languages: ',$enabled_languages);
    return $enabled_languages;
}