Example #1
0
/**
 * Load geodirectory plugin textdomain.
 *
 * @since 1.4.2
 * @package GeoDirectory
 */
function geodir_load_textdomain()
{
    /**
     * Filter the plugin locale.
     *
     * @since 1.4.2
     * @package GeoDirectory
     */
    $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
    load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
    load_plugin_textdomain('geodirectory', false, dirname(plugin_basename(__FILE__)) . '/geodirectory-languages');
    /**
     * Define language constants.
     *
     * @since 1.0.0
     */
    require_once geodir_plugin_path() . '/language.php';
    $language_file = geodir_plugin_path() . '/db-language.php';
    // Load language string file if not created yet
    if (!file_exists($language_file)) {
        geodirectory_load_db_language();
    }
    if (file_exists($language_file)) {
        /**
         * Language strings from database.
         *
         * @since 1.4.2
         */
        try {
            require_once $language_file;
        } catch (Exception $e) {
            error_log('Language Error: ' . $e->getMessage());
        }
    }
}
/**
 * Loads custom fields in to file for translation.
 *
 * @since 1.0.0
 * @package GeoDirectory
 * @global object $wpdb WordPress Database object.
 */
function geodir_diagnose_load_db_language()
{
    global $wpdb;
    $is_error_during_diagnose = geodirectory_load_db_language();
    $output_str = '';
    if ($is_error_during_diagnose) {
        $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
        $info_div_class = "geodir_problem_info";
    } else {
        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
        $info_div_class = "geodir_noproblem_info";
        $fix_button_txt = '';
    }
    echo "<ul class='{$info_div_class}'>";
    echo $output_str;
    echo $fix_button_txt;
    echo "</ul>";
}