Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I added the below code to the function.php of a .po file and finished localization and edited the webconfig.php to add Arabic language but nothing happened. I want to know what should happen. Will the site include the new language - in my situation Arabic, or what?

Now the website is in English and I want to add an Arabic version.

<?php load_theme_textdomain('themename', TEMPLATEPATH.'/language'); ?>
share|improve this question

2 Answers 2

up vote 5 down vote accepted

First, read this Codex page about translating WordPress.

You have to create a language file to put into your language directory, do this by following the next steps:

I assume you want to use poedit since you talk about a .po file

  1. download poedit
  2. File > new catalog
  3. In the first tab, fill in the fields, the most important ones are
    • Language, in your case: ar
    • Plural Forms, set this to: nplurals=2; plural=n == 1 ? 0 : 1;
  4. In the second tab, set the path to: ../ and add path: .
  5. In the last tab, add the following values:
    • __
    • _e
    • _n
    • _x:2c,1
    • _xn
    • _ex
    • esc_attr__
    • esc_attr_e
    • esc_attr_x
    • esc_html__
    • esc_html_e
    • esc_html_x
    • _n_noop
    • _nx_noop
    • translate_nooped_plural
  6. Save the catalog in your themes' languages directory as: ar.po
  7. Poedit will search for translations and then show them
  8. Translate the strings and save the file.

This .po file will contain all your translated strings wich WordPress will use to translate your added code.

To display WordPress itself in your language, download the language files from the Codex page and add them to your wordpress languages directory.

Then, in your wp-config.php, set the following line:

define( 'WPLANG', 'ar' );
share|improve this answer
    
thanks for reply but i think you didnt understand my question all what i need to know is that when i done all the steps the words translated from english to arabic but i want to have the two languages for the website not only arabic ... i mean to have a button to translate from arabic to english –  sarah Feb 13 '13 at 8:19
    
You didn't mentioned that in your question. WordPress does not support a bilingual or multilingual blog out-of-the-box. There are however Plugins developed by the WordPress community which will allow you to create a multilingual blog easily. Take a look at this page for more information. –  Mike Madern Feb 13 '13 at 8:33
    
thaanks alot mike i will check it now but one more question is it better to use that plugins or to make pages for arabic and pages for english and make a button that move you from english page to arabic page –  sarah Feb 13 '13 at 8:40
    
As you can read here, you have to choose a way adapted to the content strategy you have. SEO and experience is a important aspect. I think my choice would be a multisite solution with one multisite for English and another for Arabic content. Your choice to make a button to switch from content page is another solution you could use, and not a bad one. –  Mike Madern Feb 13 '13 at 8:54

I agree with @Mike regarding the purpose and general how to, I can just suggest that instead of using poedit, you can use a plugin called "codestyling localization" which enables editing the .po files directly from wordpress.

Also, make sure you create the appropriate .mo files, otherwise things won't be loaded.

share|improve this answer
    
thanks oferwald this plugin looks cool but can it make the 2 languages exist by adding a button at the top that transfer from english to arabic –  sarah Feb 13 '13 at 8:24
    
No, that plugin (codestyling) does not allow you to do that, if you wish to have two languages that you can switch between there are many on the repository, mine (transposh) is one of them. –  oferwald Apr 29 '13 at 10:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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