translate .po file not working - wordpress

I install wordpress in english interface.
After that I install theme(alyeska) which translate to Hebrew languege + <html dir="rtl">.
Inside the the theme folder there is lang\alyeska.po
I made some steps to be translation the alyeska.po:
I open the file alyeska.po with Poedit and change onw of the raw and I saved it as he-il.po
I edit the file function.php and add the line <?php load_theme_textdomain('alyeska'); ?> wich I don't know if it is right ('alyeska') or need other value.
I open the file wp-config.php and add the line define ('WPLANG', 'he-il');
The translation theme not working.
What I miss here ?
Many Thx.

try to change this
define ('WPLANG', 'he-il');
to
define ('WPLANG', 'he_IL');
also,
he-il.po
to
he_IL.po

Related

How to update a wordpress translation file

I want to localize a wordpress plugin and translate it to Persian with POEDIT.
I created the fa_IR.po, fa_IR.mo and all the texts loaded but when I write the translation texts and save the file, nothing happens, and it still shows me english texts in front-end.What should I do?!
Did you properly put your fa_IR.mo file in the /wp-content/languages folder?
And did you properly set define( 'WPLANG', 'fa_IR' ); in wp-config.php?
https://codex.wordpress.org/WordPress_in_Your_Language

My Wordpress theme not translate

i have a problem.I install stitch theme on wordpress and i want to translate this theme from english to persian.I create fa_IR.mo and fa_IR.po and replace in languages directory of stitch theme.Now add this bottom code to functions.php and header.php :
<?php load_theme_textdomain( 'stitch',get_template_directory().'/languages/fa_IR.mo'); ?>
but my theme still english!!!!Please help me.Where i wrong!!
Thanks alot.
I believe that the stich theme have already included a language file configuration, so you don't have to. BTW, your code should go into functions.php, and the fa_IR.mo part is not needed
All you have to do is, in your wp-config.php, look for this line
define( 'WPLANG', '' );
And change it to
define( 'WPLANG', 'fa_IR' );
This will set your language to persian
Try to use Codestyling Localization - https://wordpress.org/plugins/codestyling-localization/.
You can check if your po/mo files are in proper location, scan your template/plugins for new words for translation, etc. Very useful.

Trouble Translating a WordPress theme

I've created an Arabic website and I am using the zippy theme from MageeWP the things is that I am trying to translate some strings in the theme, but I don't seem to get it working well.
In the theme functions file, there is a specification for the folder location for .PO and .MO files
I created a file ar.mo and put it there, but it still not working, can anybody guide to a clue?
I checked in wp_config.php and indeed the WPLAND is set to ar
I also used the CodeStyling plugin to make the translation, and it didn't work, although the plugin does not problem a .po or .mo files for ONLY ar.
Additionally
the source code of the zippy theme is here: http://themes.svn.wordpress.org/zippy/1.0.9/
Looks like the theme is doing it wrong (simplified code):
define( 'ZIPPY_THEME_BASE_URL', get_template_directory_uri() );
$lang = ZIPPY_THEME_BASE_URL. '/lang';
load_theme_textdomain( 'zippy', $lang );
It's passing an URL and it should be a path, change the load_theme_textdomain line to:
load_theme_textdomain( 'zippy', get_template_directory() . '/lang');
I had a look at the Zippy theme. There are a template called en_US.po inside the lang folder. I had a look at that as well.
If you don't have poedit installed, download poedit now and install it on your computer. Now, make a copy of en_US.po and rename it ar.po. Open ar.po with poedit. Now you can do all your translations in this template. When you're done, just click save in poedit. Poedit will automatically create a ar.mo template when your ar.po is saved.
Note, this is just a quick way of doing it, as there are already a language file available that isn't yet translated.
Hope this helps

Wordpress gettext bilingual language switching for a theme

When using gettext in Wordpress to create a bilingual theme, do we have to create one .php file for every page twice (English, French)? For example, header.php, header-fr.php, sidebar.php, sidebar-fr.php, taxonomy-types.php, taxonomy-types-fr.php, etc. Sidebar-fr.php would then use _e('Text to translate', 'domain'). Is there a way to simply keep one copy of all php files and to switch the locale?
Thank you.
Create languages folder inside the theme directory, that's where you save language files, e.g. ar.po (for Arabic).
When writing strings in the code use the following (I usually use English text as the default text, so I won't need to create extra language file, and for each other language create files):
<?php echo __('This is a test','my_theme_name'); ?>
<?php _e('This is a test','my_theme_name'); ?>
in functions.php in the theme folder add the following code to load the language file (please note my_theme_name as given above):
add_action( 'after_setup_theme', 'my_theme_setup' );
function my_theme_setup(){
load_theme_textdomain('my_theme_name', get_template_directory() . '/languages');
}
This way you create only one file(header.php, index.php, etc), where strings are easy to translate.
[Note: this answer assumes that you have knowledge in how to create gettext translation files]

Wordpress, change language_attributes to return dir=rtl

In wordpress, inside the header.php file of a theme, there is the next line:
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
By default, it(language_attributes) returns dir=ltr, and every online guide i read tried to show a way to hange the css file.
it's not enough and not semantic. i need to change the html itself to rtl.
how can it be done?
is there a settings file?
You can control the text direction via the language files. If you download the Arabic(an RTL langauge) Wordpress for example.
You'll find this value is set in the \wp-content\languages\ar.php as:
$text_direction = 'rtl';
And to enable it..you need to set the WPLANG variable in your wp-config to the RTL language like this:
define ('WPLANG', 'ar');
Then your language_attributes() will output the dir='rtl' you want.
The best way to edit your default language is through the wp-config.php file on the root directory.
This case should be for Spanish of Spain
define ('WPLANG', 'es_ES');
This one to the USA English
define ('WPLANG', 'en_US');
You have all the possible combinations at this page:
http://xml.coverpages.org/iso639a.html
Regards
Take a look at the following two links. You need to ensure both of your theme and WordPress are setup for RTL.
http://codex.wordpress.org/Right_to_Left_Language_Support
http://codex.wordpress.org/Function_Reference/get_bloginfo

Resources