Steps to Create a Translation Ready Theme
- Create and load the text domain for your WordPress theme.
- Enclose the Translatable Text String with the WordPress gettext function.
- Create the POT file.
Add to style.css
/*
Theme Name: YOUR THEMENAME
Theme URI: yourdomain/themes/yourthemename/
…
…
Text Domain: yourthemename
*/
/*
Plugin Name: Plugin Name
Plugin URI: yourdomain
…
…
Text Domain: yourthemename
*/
add to functions.php
add_action('after_setup_theme', 'wpdocs_theme_setup');
/**
* Load translations for wpdocs_theme
*/
function wpdocs_theme_setup(){
load_theme_textdomain('wpdocs_theme', get_template_directory() . '/languages');
}
مثال:
<h1>Settings Page</h1>
با گذراندن رشته از طریق یک تابع محلی سازی ، می توان آن را به راحتی تجزیه و ترجمه کرد.
<h1><?php _e( 'Settings Page' ); ?></h1>