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.

Firstly i have been install wp with different languange with indonesian languange as default, i have plan, want to translate with other languange, How to simple translate switch, but keep Indonesian as default. with .po file

thanks for the help ...

share|improve this question
add comment

1 Answer 1

Assuming you're talking about the front-end and you have your strings properly internationalized, you just need to insert the load_theme_textdomain() function to tell wordpress where are your .po files.

this is how the Toolbox Theme does it:

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

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

UPDATE:

i once played with changing users locale to do that automatically, getting the users language from the $_SERVER superglobal.

i came up with this, but it's not working yet. Maybe you can work from it.

WARNING: THIS IS UNTESTED AND MIGHT BEHAVE WEIRDLY OR EVEN BREAK YOUR SITE, BE CAREFUL

function rm_get_locale($lang) {
    global $locale;
    // This gets the users' primary browser settings for acceptable languages
    // and transforms the string so it looks like en_US or pt_BR rather than
    // en-us and pt-br. It takes only the first value returned, no all of them.
    $langcode = explode(";", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
    $langcode = explode(",", $langcode['0']);
    $langcode = $langcode['0'];
    $langcode = preg_split('/-/', $langcode);
    $upper = strtoupper($langcode[1]);
    $lower = $langcode[0];

    // now we get the native wp locale and the parsed user locale
    $wplocale = get_locale();
    $userlocale = implode('_',array($lower,$upper));

    // compare them and apply the user's locale if they don't match.
    if ($userlocale != $wplocale) {
        return $userlocale;
    } else {
        return $lang;
    }


}
add_filter('locale','rm_get_locale');
share|improve this answer
    
Thank's @moraleida :) now i successful create indonesian language for default, with create .po file and locale.php at languages folder root. a little problem maybe, how can switch for english, on frontend ... very grateful for your help –  Reddy 'Rk' Aug 25 '11 at 12:10
    
Related and can be found useful by other looking wordpress.stackexchange.com/questions/31785/… –  soulseekah Mar 9 '12 at 21:58
add comment

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.