The MU forums have moved to WordPress.org

Multi language set up (59 posts)

  1. quike
    Member
    Posted 10 years ago #

    Hi Pixline, I am also very interested in the future of this project. I downloaded the files to test them, but I almost didn't get past the installation.
    I'm going to do my best to learn how to bug-track, and maybe even code, but please keep me updated.
    Thanks for your work!
    P.S. ho scoperto che siete italiani. io sono ticinese, potete scrivermi in italiano. Grazie!

  2. binh
    Member
    Posted 10 years ago #

    I'm trying to get Vietnamese for my new blog CNTT.

    Here is how it's done:
    1. I download the language file from here: http://codex.wordpress.org/WordPress_in_Your_Language#Vietnamse_-_Ti.E1.BA.BFng_Vi.E1.BB.87t_.28vi_VN.29

    2. I create a folder languages under /wp-includes
    3. I upload the file to /wp-includes/languages folder.
    4. I open the WP-Admin and Options, then change Blog Language to Vietnamese

    Hooray! It's done! :)

  3. hery
    Member
    Posted 9 years ago #

    What about this?

    http://hery.blaogy.org/2008/07/03/multi-language-plugin-for-wordpress-mu/

    It is a plugin that will do it.

    Please, put the language files inside wp-content/languages because that is the place from wpmu 1.5

  4. MazZziKa
    Member
    Posted 9 years ago #

    Any Updated .. where is the patch

  5. daily
    Member
    Posted 9 years ago #

    Well i'll repost my question here too:

    "I'm working on a new plugin that lets users choose their admin side language. This plugin only changes the admin locale, not the entire blogs. So if u have multiple authors each author can use wordpress admin in their preferred language. Each users language setting is saved in user profile in variable WP_ADMIN_LANG. The plugin automatically detecs the language files (.mo) in wp-content/languages folder and displays a dropdown box in users profile settings.

    Everything works allready this far. But tricky part is to get the actual localization to work, I havent found solution yet. I need to know when, and wich functions actually handles the loading of the locale. How can I override that function and can it be done by using action or filter hooks."

    This feature is in wordpress.com, so it shouldn't be impossible to achieve. Donncha can you point me to right direction? I would not like to touch config.php, because that would really destroy the ease of plugin installation.

    Additional feature for wpmu is ability for admins to set a default admin language.

  6. daily
    Member
    Posted 9 years ago #

    Anyone? Any help would be great, i'm kinda of stuck here.

    Here is the "working" code so far: http://pastebin.com/m24bf86b8

    I just need to know how to override wordpress locale and its ready for release.

  7. qdinar
    Member
    Posted 9 years ago #

    hello.
    i have just made gettext multilingual home and default themes:
    http://mu.wordpress.org/forums/topic.php?id=9667

  8. daily
    Member
    Posted 9 years ago #

    Could somebody just reply even to say its impossible or guide me to a site, where I could find the answer. Thanks! :)

  9. daily
    Member
    Posted 9 years ago #

    Well little progress... I found out that if WP_LANG is empty (default lang en_US), u can override to your preferred language using init hook and load_textdomain function, but it fails for some reason if WP_LANG is something else than empty.

    function load_admin_textdomain() {
    			global $locale;
    			global $l10n;
    
    			$userAdminLanguage = $this->getUserAdminLanguage();
    			if (isset($userAdminLanguage) OR !empty($userAdminLanguage)) {
    				$locale = $userAdminLanguage;
    				$mofile = ABSPATH . LANGDIR . "/$locale.mo";
    				load_textdomain('default', $mofile);
    			}
    
    		}
    
    //Filters
    add_filter('init', array($wp_adminLanguageSwitcher, 'load_admin_textdomain'));

    Google knows absolutely nothing about this either... and going line by line the core files is quite hard too because of wordpress' very nested file include structure. Is there some where a list very i could find the order of action hooks?

  10. daily
    Member
    Posted 9 years ago #

    I guess nobody here can help me. :(

    I was stuck, I had to do solve this problem somehow, so I ended up hacking wp-config.php file. Not very neat solution but deadline is deadline.

    I still want to get this plugin to work, so if you got any ideas, please post them here.

  11. neovita
    Member
    Posted 9 years ago #

    Have any of you tried Poplar Ware multi language plugin?

    http://www.poplarware.com/languageplugin.html

  12. jesse@path2u.com
    Member
    Posted 9 years ago #

    Has there ever been a good solution to this. I was looking for exactly what you had mentioned Daily. A plugin which translates the admin, and structure of wordpress. I am not concerned with the post text, as that in not accurate enough for our blog writers who will write in their native languages. I just want a language menu so viewers can see which blogs are in their languages, and get around the site to read them.
    Any ideas would be wonderful.
    thanks,
    Jesse
    jesse9goodman@gmail.com

  13. daily
    Member
    Posted 9 years ago #

    Hi Jesse,

    I got kind of stuck with my plugin and since I didn't get any help here either the plugin is still on hold. I don't know if it's done by plugin in wordpress.com or by hacking core files, but at least that shows us it is doable. I've been looking allover to solve the problems with this plugin, but I guess there isn't that many who actually knows how to manipulate/override default locale and I couldn't figure it out either. But if you do find anything that could help post links here. When I figure out how to override the basic locale, it should be only a matter of few hours to deliver a working plugin for everyone to use.

  14. RavanH
    Member
    Posted 9 years ago #

    Hi daily,

    You wrote a month ago
    [blockquote]Well little progress... I found out that if WP_LANG is empty (default lang en_US), u can override to your preferred language using init hook and load_textdomain function, but it fails for some reason if WP_LANG is something else than empty.[/blockquote]

    So what is the problem? Surely it is not much to ask of a WPMU admin who would like this too (very much, thank you ;) !) to clear the WP_LANG value in wp-config.php? In fact, it is already define('WPLANG', ''); in mine...

    Or do I misunderstand you here?

  15. daily
    Member
    Posted 9 years ago #

    Hi RanvanH,

    If you run multiple blogs with MU with multiple languages, WP_LANG is saved in wp_options table. So wp-config.php is untouched in that case too.

    I just tried overriding the locale function with add_filter and it seems to work fine. I don't know why it didn't work earlier when i tried it? You can use the previous code, just switch the add_filter to this:

    //Filters
    	if (is_admin())
    	    add_filter('locale', array($wp_adminLanguageSwitcher, 'load_admin_textdomain'));

    I'll do some more testing, clean up the code and release the entire plugin some time near future.

  16. path2u
    Member
    Posted 9 years ago #

    hey Daily, it sounds like you have made some progess with this. Let me know if there is a way I can make a donation to your efforts, as I plan on using them as well if possible.
    I know very little about coding, so I am all for a working plugin as well.
    thanks

  17. goko
    Member
    Posted 9 years ago #

    Excuse my ignorance but where shall I paste daily's code?

  18. daily
    Member
    Posted 9 years ago #

    I have now a working set of the plugin. It will ONLY change the admin side language and the language can be selected on profile page. It has some bug with russian language pack, but any other language that I have tested with "normal" characters works fine. To use the plugin you need to download the language files for each language you want to use and upload them normally to languages folder.

    I'll try publish a working plugin in a month or so.

    goko: if u wanna use that code u have to build up a plugin.

  19. qdinar
    Member
    Posted 9 years ago #

    http://mu.wordpress.org/forums/topic.php?id=10915 "guest language selection".
    now i have home page quickly can change language this way. i have added "?l=en" like links to multilingual home theme. current language is saved in cookie. but now i want to use non-multilingual home themes because multilingual is hard to modify. for that i should find the place where theme is selected and select it according to cookie in that place. i have found this place in wp-settings.php:
    do_action('setup_theme');
    define('TEMPLATEPATH', get_template_directory());
    define('STYLESHEETPATH', get_stylesheet_directory());
    .
    i know now that i probably can change $locale with apply_filters.

  20. qdinar
    Member
    Posted 9 years ago #

    that themes was not all correct that are in http://mu.wordpress.org/forums/topic.php?id=2042&page=2#post-57965 in this topic.

  21. qdinar
    Member
    Posted 9 years ago #

    now i cannot edit. but that commands that are in the post that is previous of previous post are with comments between them.

  22. mikaelwehner
    Member
    Posted 9 years ago #

    Daily, how is the plugin comming along? Will it work for an ordinary WP site as well?

  23. dsalon
    Member
    Posted 9 years ago #

    we are currently developing a plugin which will comprise a plurality of multi language features, whereby there will be an wpmu-admin version, a wp version and also a combined version... it is the combined version, which will comprise said plurality of features...

    actually todate we are not sure, if we will make all features available to the public, maybe we will try to share with some of these wpmudev premium plugins...

    you can fand the wpmu-admin version below, simply copy the files in the appropriate directories:

    <?php
    /*
    Plugin Name: WPMU-Default-Language
    Plugin URI: http://weshalltelyoulater.net/
    Description: Creates a blog in a selected language and lets you select the language of the entire site and of individual blogs.
    Author: tpd
    Version: 0.0.8
    Author URI: http://weshalltelyoulater.net/
    */

    include (dirname(__FILE__) . '/wpmu/' . basename(__FILE__));

    ?>

    <?php
    /*
    Plugin Name: WPMU-Default-Language
    Plugin URI: http://weshalltelyoulater.net/
    Description: Creates a blog in a selected language and lets you select the language of the entire site and of individual blogs.
    Author: tpd
    Version: 0.0.8
    Author URI: http://weshalltelyoulater.net/
    */

    load_textdomain('wpmu', ABSPATH . 'wp-content/mu-plugins/wpmu/languages/wpmu_' . WPLANG . '.mo');

    function wpmu_language_dict($value) {

    $l_dict['bg_BG'] = __('Bulgarian', 'wpml');
    $l_dict['cs_CZ'] = __('Czech', 'wpml');
    $l_dict['da_DK'] = __('Danish', 'wpml');
    $l_dict['de_DE'] = __('German', 'wpml');
    $l_dict['en_EN'] = __('English', 'wpml');
    $l_dict['es_ES'] = __('Espanol', 'wpml');
    $l_dict['fr_FR'] = __('French', 'wpml');
    $l_dict['hu_HU'] = __('Hungarian', 'wpml');
    $l_dict['it_IT'] = __('Italiano', 'wpml');
    $l_dict['jp_JP'] = __('Japanese', 'wpml');
    $l_dict['nl_NL'] = __('Netherlands', 'wpml');
    $l_dict['pl_PL'] = __('Polish', 'wpml');
    $l_dict['pt_PT'] = __('Portuguese', 'wpml');
    $l_dict['sr_RS'] = __('Serbian', 'wpml');
    $l_dict['sv_SE'] = __('Swedish', 'wpml');
    $l_dict['ru_RU'] = __('Russian', 'wpml');
    $l_dict['ua_UA'] = __('Ukranian', 'wpml');
    $l_dict['00_00'] = __('not specified', 'wpml');

    if ($l_dict[$value] == '') {

    return $value;

    } else {

    return $l_dict[$value];

    }
    }

    function wpmu_language_select($wpmu_lang) {

    $dir = ABSPATH . 'wp-content/languages/';

    $verz=opendir($dir);

    $ext = '.mo';

    $i = 0;

    $lang_array = array();

    while($file = readdir($verz)){
    if($file != '.' && $file != '..' && (substr($file, -3)) == $ext) {
    $lang_array[$i] = substr($file, 0, 5);
    $i++;
    }
    }
    closedir($verz);

    $lang_array[$i] = 'en_EN';

    asort($lang_array);

    foreach ( $lang_array as $key => $value )
    {

    if ($value == $wpmu_lang) {

    $output .= "<option selected value=\"" . $value . "\">" . wpmu_language_dict($value) . "</option>";

    } else {

    $output .= "<option value=\"" . $value . "\">" . wpmu_language_dict($value) . "</option>";

    }
    }

    echo $output;

    }

    ////////////

    function wpmu_language_pre_select() {

    if(isset($_POST['wpmu_lang'])) {
    $wpmu_lang = $_POST['wpmu_lang'];
    } else {
    $wpmu_lang = get_option('WPLANG');
    }

    ?>
    <label for="wpmu_lang"><span class="prefix_address"><?php _e('Language', 'wpmu')?></span></label>
    <?php

    wpml_wpmu_signup_extra_fields($wpmu_lang);

    }

    ////////////////////////////////////

    function wpml_wpmu_site_language($wpmu_site_lang)
    {
    ?>

    <select style="font-size: 18px; border: 1px solid #e5e5e5; font-family: 'Lucida Grande', Verdana, Arial, 'Bitstream Vera Sans', sans-serif; color: #333;" name="wpmu_site_lang">
    <?php
    $wpmu_lang = $wpmu_site_lang;
    wpmu_language_select($wpmu_lang);
    ?>
    </select>

    <?php
    }

    ////////////////////////////////////

    function wpml_wpmu_language($wpmu_lang)
    {
    ?>

    <select style="font-size: 18px; border: 1px solid #e5e5e5; font-family: 'Lucida Grande', Verdana, Arial, 'Bitstream Vera Sans', sans-serif; color: #333;" name="wpmu_lang">
    <?php
    wpmu_language_select($wpmu_lang);
    ?>
    </select>

    <?php
    }

    //////////////////////////////////

    function wpml_wpmu_signup_extra_fields($wpmu_lang)
    {
    ?>

    <select style="
    -moz-border-radius: 4px;
    -khtml-border-radius: 4px;
    -webkit-border-radius: 4px;
    background: #fbfbfb; font-size: 18px; border: 1px solid #e5e5e5; font-family: 'Lucida Grande', Verdana, Arial, 'Bitstream Vera Sans', sans-serif; color: #333;" name="wpmu_lang">
    <?php

    wpmu_language_select($wpmu_lang);
    ?>
    </select>

    <?php
    }

    function wpml_wpmu_signup_blog_init($content)
    {
    if(isset($_POST['wpmu_lang'])) {
    $content['wpmu_lang'] = $_POST['wpmu_lang'];
    return $content;
    }
    }

    function wpml_wpmu_add_signup_meta($meta)
    {
    if(isset($_POST['wpmu_lang'])) {
    $meta['WPLANG'] = $_POST['wpmu_lang'];
    return $meta;
    }
    }

    function wpml_wpmu_manage_page() {

    if ('wpmu_process' == $_POST['wpmu_stage'])
    {

    if(isset($_POST['wpmu_lang']))
    update_option('WPLANG', $_POST['wpmu_lang']);

    if(isset($_POST['wpmu_site_lang']))
    update_site_option('WPLANG', $_POST['wpmu_site_lang']);

    }

    $wpmu_site_lang = get_site_option('WPLANG');

    $wpmu_lang = get_option('WPLANG');

    echo "<div class='wrap'><h2>" . __( 'Language Setting', 'wpmu' ) . "</h2>";

    echo '<h3>' . __( 'Site Admin Configuration', 'wpmu' ) . '</h3>';
    echo '<form method="POST">';
    echo '<input type="hidden" name="wpmu_stage" value="wpmu_process" />';
    if( is_site_admin() ) {
    echo "<p>" . __( 'As a site admin on this site you can set the language of your entire site.', 'wpmu' ) . "</p>";
    wpml_wpmu_site_language($wpmu_site_lang);
    }

    echo "
    ";
    echo "<p>" . __( 'As a blog admin you can set the language of your site.', 'wpmu' ) . "</p>";
    wpml_wpmu_language($wpmu_lang);

    echo "<p class='submit'><input type='submit' value='" . __( 'Update', 'wpmu' ) . " »' /></p>";
    echo "</form>
    ";
    echo "</div>";
    ?>
    <div class='wrap'><h2><?php _e('Comments', 'wpmu') ?></h2>
    <fieldset class="options">

    <table width="100%" cellpadding="5" class="editform">
    <tr valign="top">
    <td>
    <?php _e('Install, activate, have fun... be happy!', 'wpmu') ?></td>
    </tr>
    <tr valign="top">
    <td>
    <?php _e('For further information please visit the Plugin Author', 'wpmu') ?> ... </td>
    </tr>
    </table>
    </fieldset>
    <p class="submit">

    </p>
    </div>
    <?php
    }

    function wpml_wpmu_add_pages() {

    $menu = __('Language', 'wpmu');

    if( is_site_admin() ) {
    $submenu = __('Language settings', 'wpmu');
    $option_file = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
    add_submenu_page('wpmu-admin.php', 'Language', $menu, 0, $option_file, 'wpml_wpmu_manage_page');
    }
    else {
    $submenu = __('Language options', 'wpmu');
    add_management_page($menu, $submenu, 'manage_options', 'languagesettings', 'wpml_wpmu_manage_page');
    }
    }

    add_action('admin_menu', 'wpml_wpmu_add_pages');

    add_filter('signup_blog_init', 'wpml_wpmu_signup_blog_init');

    // add_filter('signup_another_blog_init', 'wpml_wpmu_signup_blog_init');

    add_action('signup_extra_fields', 'wpmu_language_pre_select');

    add_action('signup_blogform', 'wpmu_language_pre_select');

    add_filter('add_signup_meta', 'wpml_wpmu_add_signup_meta');

    ?>

    Install, use, enjoy... be happy!

  24. dsalon
    Member
    Posted 9 years ago #

    of course you will have your selected language files uploaded and the define WP_LANG command uncommented in your wp-config file...

  25. mattiasantin
    Member
    Posted 9 years ago #

    Hi Dsalon,

    can you tell me in which directories I should copy the files you posted?

    Thanks

  26. simonwheatley
    Member
    Posted 9 years ago #

    Daily - Is your plugin anywhere I can see, please?

  27. andrea_r
    Moderator
    Posted 9 years ago #

    Have a look at http://wpml.org/

  28. dsalon
    Member
    Posted 9 years ago #

    actually this wpml.org project appears to be kind of interesting and a directly competitive system to ours... hey that is very welcome! ... maybe we can co-operate in future...

    particularly since their approach and overall concept is completely different to ours which will enable similar multilingual features as the wordpress.com site...

    now please excuse our post above... which occurred maybe somewhat overhastly...

    as you know all of these software projects need twice more time as you need...

    to date we expect the release of our first publicly available wpml(mu) plugin in about two or three weeks...

    then you will also receive detailed instructions on the installation and features and you can test it, whereby you may learn the differences between our approach and the wpml.org approach, whereby this onthegosystems.inc. behind currently appears from our understanding rather mysterious....

    so thank you again for your understanding for our maybe overhastly post and the further time we need our the first publicly available release...

  29. andrea_r
    Moderator
    Posted 9 years ago #

    Next time, please don;t post such long code. Link to a file or pastebin.

    Keeps the thread shorter. :)

About this Topic

  • Started 11 years ago by agent14
  • Latest reply from andrea_r