• Resolved chestnut_jp

    (@chestnut_jp)


    The plugin won’t accept any Japanese characters.
    All Japanese somehow change to “?”.

    User Name for Buddypress cannot be set to 2-byte characters, thus most Japanese use Japanese (2-byte characters) for their nicknames.

    When you set User Name to use Ajax Chat, the user name, which is not Japanese, is shown. However, when you set it to Nickname, which is Japanese (2-byte characters), it becomes only “???”.

    At the same time, we cannot chat in Japanese, the plugin anyway seems to accept only one-byte characters. Thus, we have no choice but to chat in English, which is very much inconvenience.

    Does anyone have any idea to fix this problem, for this trouble has long been though I already reported before…

Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author dfa3272008

    (@dfa3272008)

    Any way I can get access to the site and work on it remotely? I don’t have a 2-byte setup. I thought I took care of this, but if you’re still reporting it then something else must be missing and as you can tell…I didn’t test it;)

    Thread Starter chestnut_jp

    (@chestnut_jp)

    Thank you for your reply.

    To be honest, I have already used the plugin in Japanese.
    Since it is a kind of rough alternation, I do not think you will implement it.

    However, I will report what I did to use the plugin in Japanese, because it is not a matter of Japanese, but I suppose it is for all people using 2-byte characters.

    Though I said it’s rough, it is really simple.

    Just change the type of “userName”, “ip”, and “text” in tables of ajax_chat_online, ajax_chat_messages, and ajax_chat_bans to VARBINARY. That’s it. You can see 2-byte characters like Japanese properly.

    By the way, the plugin’s Flex/Ajax bridge (FABridge.js) is out-of-date, and error message of “TypeError: Object #<an HTMLObjectElement> has no method ‘create'” is shown when browsing by Google Chrome.

    This is fixed by replacing the file with a new one.

    The new one is available at:
    https://fpdownload.adobe.com/pub/flex/sdk/builds/flex4/flex_sdk_4.1.0.16032_mpl.zip

    This must be included in the plugin to be updated.

    Plugin Author dfa3272008

    (@dfa3272008)

    Hi,

    I thought utf-8 would suffice. That’s what I use. To change variables to varbinary isn’t correct I think. There has to be another way. Utf-8 supports it.

    What does your DB_CHARSET variable state in your wp-config.php file? Perhaps I should make the tables match that instead of calling out utf8? Please let me know.

    Thanks,
    Dave

    Thread Starter chestnut_jp

    (@chestnut_jp)

    Yes, I use utf-8. Other plugins I use with buddypress are all working properly.

    I alreaday tried various ways, for instance changing the charset from utf-8 to euc or jis, changing variables to other than VARBINARY, and all my trials failed.

    Just one thing I suppose to be a reason is something like what we Japanese see everytime buddypress is upgraded:

    When new BuddyPress is released, we Japanese have to change the line 1031 of bp-activity-templatetags.php as following:

    [ Original ]
    $title = trim( strip_tags( html_entity_decode( utf8_encode( $content[0] ) ) ) );
    
    [ Changed ]
    $title = trim( strip_tags( html_entity_decode( $content[0] ) ) );

    Otherwise Japanese characters in RSS feeds can not read.

    I first thought that the same thing might happen in the plugin. However, I have not yet found it.

    After changing variables in many ways, only VARBINARY shows Japanese characters right. Thus, I decided to use it. Yes, I know it is not the correct fix.

    I still am searching the best solution.

    Plugin Author dfa3272008

    (@dfa3272008)

    Hi,

    At the top of the chat pages what does ? show in lang=”?”?

    I think it might be because the language code isn’t in chat. If so then the html page doesn’t get rendered right.

    See here:
    function getLangCode() {
    // Get the langCode from request or cookie:
    $langCodeCookie = isset($_COOKIE[$this->getConfig(‘sessionName’).’_lang’]) ? $_COOKIE[$this->getConfig(‘sessionName’).’_lang’] : null;
    $langCode = $this->getRequestVar(‘lang’) ? $this->getRequestVar(‘lang’) : $langCodeCookie;
    // Check if the langCode is valid:
    if(!in_array($langCode, $this->getConfig(‘langAvailable’))) {
    // Determine the user language:
    $language = new AJAXChatLanguage($this->getConfig(‘langAvailable’), $this->getConfig(‘langDefault’));
    $langCode = $language->getLangCode();
    }
    return $langCode;
    }

    I pass the language from the wp-config file and if it’s not one of these then who knows how the page is encoded and hence why varbinary might work.

    List:
    ar.js
    bg.js
    bp.js
    ca.js
    cy.js
    cz.js
    de.js
    el.js
    en.js
    es.js
    fi.js
    fr.js
    gl.js
    he.js
    hr.js
    hu.js
    in.js
    it.js
    ja.js
    ka.js
    kr.js
    nl.js
    no.js
    pl.js
    ro.js
    ru.js
    sk.js
    sl.js
    sr.js
    sv.js
    tr.js
    uk.js
    zh-tw.js
    zh.js

    Thread Starter chestnut_jp

    (@chestnut_jp)

    Thank you for youe continued help.

    First of all, ja.js is lised in the list you showed above.

    Secondly, source of the chat top page reads:
    <html xmlns="https://www.w3.org/1999/xhtml" dir="ltr" lang="ja">

    This is written the second line, right after:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    A little bit below, it reads:
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    Plugin Author dfa3272008

    (@dfa3272008)

    Hi,

    For kicks try replacing UTF-8 with SHIFT_JIS in the meta tag.

    You can replace it directly in to the template for now. The template is bp-chat/chat/lib/template/loggedIn.html.

    Also, what does a working Japanese website look like? That would help me.

    Thanks,
    Dave

    Thread Starter chestnut_jp

    (@chestnut_jp)

    Changing UTF-8 to SHIFT_JIS or SJIS is not effective. The problem remains.
    I tried in various ways, like once again changing charset of database to SJIS, in vain.

    Since characters in database become ???, I think something somewhere in the plugin scripts change characters code before inserting into database.

    In order to confirm this, I need to know how the plugin handle characters especially right before inserting them into database.

    Could you please the point where characters are converted or processed in the scripts, because the scripts are complicated for me to follow.

    Plugin Author dfa3272008

    (@dfa3272008)

    Hi,

    I think I got it. In wp-db.php right after the db makes a connection in the wpdb function you need to add this code:

    mysql_query(“SET NAMES ‘utf8′”);

    This should take care of chat and wordpress for you. Please let me know how you make out.

    Thanks,
    Dave

    Thread Starter chestnut_jp

    (@chestnut_jp)

    I added “mysql_query(“SET NAMES ‘utf8′”);” to the line right after “$this->db_connect();” in wp-db.php.

    “$this->db_connect();” is at the line of 480 and is within “function wpdb( $dbuser, $dbpassword, $dbname, $dbhost ).

    In order to see whether this addition solves the problem, I re-create chat tables with the default attributes because I changed attributes to varbinary.

    The result is…
    Sorry, but no change. Japanese words are still restored in the database as ???.

    Plugin Author dfa3272008

    (@dfa3272008)

    Hi,

    Hmm, there may be yet another place things are stored without utf8 and set names. You need to call that line out for each mysql connection in order for it to work.

    For kicks did you notice chat groups displayed correctly? I specifically call that out. I’m curious as I want to be sure I’m on the right track here.

    Thanks,
    Dave

    Thread Starter chestnut_jp

    (@chestnut_jp)

    Oh I forgot to tell you something.

    First, I changed around the line 246 of /bp-chat/chat/lib/class/CustomAJAXChat.php as following:

    [ Original ]
    if ($row[‘user_nicename’] == “admin”)

    [ Changed ]
    if ($row[‘user_nicename’] == “xxxxxx”)

    Note that xxxxxxx is not the real username. I hide the real username for security reason, because it is Administrator’s username.

    I changed “admin” to “xxxxxx” because I created Administrator not as admin but as xxxxxx, and the plugin did not allow xxxxxx to use the command of “/whois” and others that only moderators can use.

    However, when I open the chat page, there is a message of “Admin is offline”. Since this does not seem to have any influence on chat itself, I have commented it out not to be displayed.

    So, the answer to your question whether chat groups are disopaly correctly, is “NO”.

    I must go to bed as it is already 2:13 am here in Japan.

    Plugin Author dfa3272008

    (@dfa3272008)

    Hi,

    Your info is very helpful. I think this will fix the chat ??? issue.

    in bp-chat/chat/lib/class/AJAXChatDataBase.php replace the original function for connect with this:

    // Method to connect to the DataBase server:
    function connect(&$dbConnectionConfig) {
    $this->_connectionID = @mysql_connect(
    $dbConnectionConfig[‘host’],
    $dbConnectionConfig[‘user’],
    $dbConnectionConfig[‘pass’],
    true
    );
    if(!$this->_connectionID) {
    $this->_errno = null;
    $this->_error = ‘Database connection failed.’;
    return false;
    }
    #This handles Russian characters
    mysql_query(“SET NAMES ‘utf8′”);
    return true;
    }

    Thanks,
    Dave

    Thread Starter chestnut_jp

    (@chestnut_jp)

    Very strange phenomenon happened.

    First I upgraded the plugin to the latest 1.3.6.
    I re-created database tables with default valiables for verification.

    Before adopting your suggestion, I tried chattgin.
    Wow, Japanese shows correctly, and there are proper Japanese in the database.

    Adopting your suggestion to 1.3.6, on the other hand, results in the fact that null (= empty) in tables.

    For this reason, I will continue using the default 1.3.6 for a while to see if it is really correcting the problem. I will send you Japanese Translation when I confirm it is OK. But, I do not know the way to send it to you.

    Nevertheless, “Admin is offline” is still shown in the chat page, though I changed admin to xxxxxx at the line 246 of /bp-chat/chat/lib/class/CustomAJAXChat.php, in order for me to use commands exclusive to moderators. I do not know how to fix this.

    Plugin Author dfa3272008

    (@dfa3272008)

    Hi,

    You lost me a little bit. I’m confused as to what worked for you and what didn’t.

    On the dynamicendeavorsllc.com site there’s a contact form now and you can send me the translation that way:)

    Thanks,
    Dave

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘[Plugin: Buddypress-Ajax-Chat] Ajax Chat won't work with Japanese’ is closed to new replies.