0

i translate many wp themes until now and i don't see this problem yet.

I make mo and po files for this theme and in the function i put this code

load_theme_textdomain( 'rokesh', get_template_directory() .'/lang/');

and i change all theme textdomains to rokesh and also translate all texts in poedit and it work correctly in the localhost. but when i move this theme to the real host the translated texts not working. What's the problem?

you can downlod the translated theme here : http://persianupload.com/kleeja/do.php?filename=139403225540321.zip

and it's all content of the function file of this theme:

<?php
/**
 * web2feel functions and definitions
 *
 * @package web2feel
 */

load_theme_textdomain( 'rokesh', get_template_directory() .'/lang/');

$locale = get_locale();
$locale_file = get_template_directory() . "/languages/$locale.php";
if ( is_readable( $locale_file ) ) {
    require_once( $locale_file );
}

include ( 'getplugins.php' );
include ( 'aq_resizer.php' );
include ( 'guide.php' );


/* Custom style */

function custom_style() { 
    $main_color  = of_get_option('w2f_primary_color');
    $link_color  = of_get_option('w2f_link_color');
    $hover_color = of_get_option('w2f_hover_color');
?>
    <style type="text/css">

        .top-feature,.main-navigation ul > li a:hover,h1.widget-title, h3.sidetitl,#side-tab{ background: <?php echo $main_color ?>; }
        a,a:visited{ color:<?php echo $link_color ?>;}
        a:hover,a:focus,a:active { color:<?php echo $hover_color ?>; }

    </style>
<?php }

add_action( 'wp_footer', 'custom_style' );


/* Theme updater */
require 'updater.php';
$example_update_checker = new ThemeUpdateChecker(
    'Yegor',                                            //Theme folder name, AKA "slug". 
    'http://www.fabthemes.com/versions/yegor.json' //URL of the metadata file.
); 


/**
 * Set the content width based on the theme's design and stylesheet.
 */
if ( ! isset( $content_width ) )
    $content_width = 640; /* pixels */

if ( ! function_exists( 'web2feel_setup' ) ) :
/**
 * Sets up theme defaults and registers support for various WordPress features.
 *
 * Note that this function is hooked into the after_setup_theme hook, which runs
 * before the init hook. The init hook is too late for some features, such as indicating
 * support post thumbnails.
 */
function web2feel_setup() {

    /**
     * Make theme available for translation
     * Translations can be filed in the /languages/ directory
     * If you're building a theme based on web2feel, use a find and replace
     * to change 'rokesh' to the name of your theme in all the template files
     */
    /**


     * Add default posts and comments RSS feed links to head
     */
    add_theme_support( 'automatic-feed-links' );

    /**
     * Enable support for Post Thumbnails on posts and pages
     *
     * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
     */
    add_theme_support( 'post-thumbnails' );

    /**
     * This theme uses wp_nav_menu() in one location.
     */
    register_nav_menus( array(
        'primary' => __( 'Primary Menu', 'rokesh' ),
    ) );

    /**
     * Enable support for Post Formats
     */
    //add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) );

    /**
     * Setup the WordPress core custom background feature.
     */
/*
    add_theme_support( 'custom-background', apply_filters( 'web2feel_custom_background_args', array(
        'default-color' => 'ffffff',
        'default-image' => '',
    ) ) );
*/
}
endif; // web2feel_setup
add_action( 'after_setup_theme', 'web2feel_setup' );

/**
 * Register widgetized area and update sidebar with default widgets
 */
function web2feel_widgets_init() {
    register_sidebar( array(
        'name'          => __( 'Sidebar', 'rokesh' ),
        'id'            => 'sidebar-1',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget'  => '</aside>',
        'before_title'  => '<h1 class="widget-title">',
        'after_title'   => '</h1>',
    ));

    register_sidebar(array(
        'name' => 'Footer',
        'before_widget' => '<div class="botwid col-sm-6 col-md-3 %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h3 class="bothead">',
        'after_title' => '</h3>',
    )); 
}
add_action( 'widgets_init', 'web2feel_widgets_init' );

/**
 * Enqueue scripts and styles
 */
function web2feel_scripts() {
    wp_enqueue_style( 'web2feel-style', get_stylesheet_uri() );
    wp_enqueue_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css');
    wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/bootstrap/bootstrap.css');
    wp_enqueue_style( 'bootstrap-glyphicons', get_template_directory_uri() . '/css/bootstrap-glyphicons.css');
    wp_enqueue_style( 'theme', get_template_directory_uri() . '/css/theme.css');

    wp_enqueue_script( 'jquery');
    wp_enqueue_script( 'mobilemenu', get_template_directory_uri() . '/js/mobilemenu.js', array( 'jquery' ), '20120206', true );
    wp_enqueue_script( 'flexslider', get_template_directory_uri() . '/js/flexslider.js', array(), '20120206', true );   
    wp_enqueue_script( 'jquery.carouFredSel', get_template_directory_uri() . '/js/jquery.carouFredSel-6.2.1-packed.js', array(), '20120206', true );
    wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/bootstrap/bootstrap.min.js', array( 'jquery' ), '20120206', true );
    wp_enqueue_script( 'web2feel-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20120206', true );
    wp_enqueue_script( 'custom', get_template_directory_uri() . '/js/custom.js', array(), '20120206', true );

    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }


}
add_action( 'wp_enqueue_scripts', 'web2feel_scripts' );

/**
 * Implement the Custom Header feature.
 */
//require get_template_directory() . '/inc/custom-header.php';

/**
 * Custom template tags for this theme.
 */
require get_template_directory() . '/inc/template-tags.php';

/**
 * Custom functions that act independently of the theme templates.
 */
require get_template_directory() . '/inc/extras.php';

/**
 * Customizer additions.
 */
//require get_template_directory() . '/inc/customizer.php';

/**
 * Load Jetpack compatibility file.
 */
//require get_template_directory() . '/inc/jetpack.php';

require get_template_directory() . '/inc/paginate.php';

/* Exclude pages from search results */

function mySearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}

add_filter('pre_get_posts','mySearchFilter');


/*
 * Helper function to return the theme option value. If no value has been saved, it returns $default.
 * Needed because options are saved as serialized strings.
 *
 * This code allows the theme to work without errors if the Options Framework plugin has been disabled.
 */
if ( !function_exists( 'of_get_option' ) ) {
function of_get_option($name, $default = false) {
    $optionsframework_settings = get_option('optionsframework');
    // Gets the unique option id
    $option_name = $optionsframework_settings['id'];
    if ( get_option($option_name) ) {
        $options = get_option($option_name);
    }
    if ( isset($options[$name]) ) {
        return $options[$name];
    } else {
        return $default;
    }
}
}



/* Credits */

function selfURL() {
$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] :
$_SERVER['PHP_SELF'];
$uri = parse_url($uri,PHP_URL_PATH);
$protocol = $_SERVER['HTTPS'] ? 'https' : 'http';
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
$server = ($_SERVER['SERVER_NAME'] == 'localhost') ?
$_SERVER["SERVER_ADDR"] : $_SERVER['SERVER_NAME'];
return $protocol."://".$server.$port.$uri;
}
function fflink() {
global $wpdb, $wp_query;
if (!is_page() && !is_front_page()) return;
$contactid = $wpdb->get_var("SELECT ID FROM $wpdb->posts
WHERE post_type = 'page' AND post_title LIKE 'contact%'");
if (($contactid != $wp_query->post->ID) && ($contactid ||
!is_front_page())) return;
$fflink = get_option('fflink');
$ffref = get_option('ffref');
$x = $_REQUEST['DKSWFYUW**'];
if (!$fflink || $x && ($x == $ffref)) {
$x = $x ? '&ffref='.$ffref : '';
$response = wp_remote_get('http://www.fabthemes.com/fabthemes.php?getlink='.urlencode(selfURL()).$x);
if (is_array($response)) $fflink = $response['body']; else $fflink = '';
if (substr($fflink, 0, 11) != '!fabthemes#')
$fflink = '';
else {
$fflink = explode('#',$fflink);
if (isset($fflink[2]) && $fflink[2]) {
update_option('ffref', $fflink[1]);
update_option('fflink', $fflink[2]);
$fflink = $fflink[2];
}
else $fflink = '';
}
}
echo $fflink;
}
  • Does the translation work on other hosts? WordPress uses the gettext PHP extension, which is standard and enabled by default, but it is possible to disable it. It would be weird, but that could be the problem. – s_ha_dum Mar 5 '14 at 15:23
  • i test it in two host but it's not work. and i also use other themes in that host but other themes translation's work well. – saeed shabani Mar 5 '14 at 15:26
  • Then post your code. Something is wrong with it. – s_ha_dum Mar 5 '14 at 15:30
  • post what code? – saeed shabani Mar 5 '14 at 15:31
  • 1
    the difference between the original theme and your version is that you've moved the load_theme_textdomain call outside of the correct after_setup_theme hook, not sure if that breaks things or not though. – Milo Mar 5 '14 at 16:29
0

Thanks all friends. Finally i found the problem.

i must use

fa_IR.mo

instead of

fa_IR.MO

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.