WordPress.org

Forums

Events Manager
[resolved] some strings in Chinese translation .po file don't work (32 posts)

  1. omegacoder
    Member
    Posted 2 years ago #

    some of the translation strings don't work. namely, "Event Tags" and "search for events"

    I've looked at the dbem-zh_CN.po file and the translations are there (search for events = 搜索活动) But the chinese version doesn't show up on chinese site. I've updated the .mo file also, tried the update from .pot file too

    The output code is:
    <input type="text" class="search_input" value="<?php _e('search for events', 'dbem'); ?>"

    Is my mistake obvious to someone. I really appreciate any help. I've spend some time on this already!

    http://wordpress.org/extend/plugins/events-manager/

  2. agelonwl
    Member
    Posted 2 years ago #

    try Settings > Formatting > Search Form

  3. omegacoder
    Member
    Posted 2 years ago #

    that only applies for the events list search filter. I've got mine as a sidebar (which is not part of events manager). Actually I just realized that maybe this is why the translation is not showing, because my code above is not in the events manager plugin where the .po, .mo files are.

    ill do some tests and report back for everyones information

    check out http://www.jesstown.com/cn (see side bar), to see what I mean.

    Also, my translation for "Event Tags" isn't showing, and this I believe is part of events manager plugin, which is not showing in chinese also

  4. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    I haven't ever specifically tested this, but I'd imagine it should work since you have the 'dbem' in there. However, given that the po/mo files take lines numbers into accounts (e.g. open up the po file in a text editor), I may be wrong.

    Maybe it's because your string doesn't match the translated ones for capitalizations?

    Try out dev version 5.2.9.1 btw, it has some corrections to language translation functions. To update visit Events> Settings > General > Admin Tools

  5. omegacoder
    Member
    Posted 2 years ago #

    yes you are right it should work. It's all from the events manager plugin default, so I hadn't changed anything there.

    I expected this to simply work. But it hasn't. I checked the dbem-zh_CN.po file and it does contain the correct translations for relevant strings, but it doesn't show up on my chinese version website when I call it in my theme, like this

    <input type="text" class="search_input" value="<?php _e('search for events', 'dbem'); ?>" />

    I'm using a childtheme by the way, but I don't see how this matters, I have other translations that work alright both in other plugins and this childtheme

  6. omegacoder
    Member
    Posted 2 years ago #

    also maybe relevant, I'm using wordpress multisite, the main site is english and subsite chinese

  7. agelonwl
    Member
    Posted 2 years ago #

    Does your EM installation is network activated and/or enable global tables mode ?

  8. omegacoder
    Member
    Posted 2 years ago #

    yes, it's network activated. what is enable global tables mode?

  9. omegacoder
    Member
    Posted 2 years ago #

    ok, just checked no, it's not in global tables mode

  10. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    MS wouldn't make a difference. Nor would a child theme. If it's not within the plugin and the po/mo isn't regenerated, then it won't work.

    Try using get_locale() and then output the translations directly using an php if statement.

    http://codex.wordpress.org/Function_Reference/get_locale

    Or, wrap this code in your own plugin and add your own language file :)

  11. omegacoder
    Member
    Posted 2 years ago #

    well if I use the get_lcale() and output the translations that way, isn't this a messy hack?

    I've regenerated the .po, .mo file many times without it working. Also within my theme, I have buddypress translations, so perhaps the translations will work still even if not in the plugin, I think you just have to referene the text domain e.g. _e('my text','buddypress);

    anyway, about this get_locale() hack can you provide some sample code to set me on the right track? although I have quite a few translations remaining, so this really would be a last resort

  12. omegacoder
    Member
    Posted 2 years ago #

    when I echo my locale it always shows en_US

    echo $locale = get_locale();

    But I've set the language of my subsite to chinese, and it still displays the locale as en_US (settings > general, site language set to chinese)

  13. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    If you're already using custom code, the it wouldn't be that messy of a hack, you'd do

    $string = 'english string';
    if( get_locale() == 'x'){
      $string = 'other language';
    }

    What are you using to translate? get_locale() should show the current language WP is using, but maybe your language plugin has its own function to check the current language.

  14. omegacoder
    Member
    Posted 2 years ago #

    Thanks marcus for all your assitance!

    For me, using get_locale() always output en_US, so I couldn't use that. I don't have time now to dig and find out why. I'm really disappointed I couldn't get the translations through. I've tried regenerating the .po file many times, and I see the translation strings in the .po file. My .mo file is also regenerated, but they just don't show on my website for some reason. Does anyone else have this problem? Is my poedit software buggy? No, it works for my own custom plugin. I would really want to the solution

    As to your suggested solution, I'm doing something similar now, although i'm a bit uncomfortable with these unclean quick fixes, because they really should be translated through the .po,.mo files, but as a practical solution, that's what I'll have to do - for now anyway

    For everyone reading this, I've used the following solution:

    my theme function file:

    global $blog_id;
    // using multisite, $blog_id=1 refers to main site
    switch($blog_id) {
    case 1:
    default:
    define('TXT_SEARCH_FOR_EVENTS', 'search for events');
    // etc
    break;
    case 2:
    define('TXT_SEARCH_FOR_EVENTS','搜索您感兴趣的活动');
    // etc
    break;
    }

    So I put all the non-working translations in the case, the rest was successsfully translated in the .op, .mo files

  15. omegacoder
    Member
    Posted 2 years ago #

    how would I change the language of the word "events" in the tab menu when you visit the buddypress group detail page. Is this from the database by default?

    e.g:

    http://www.jesstown.com/cn/activity-groups/business/hierarchy/

  16. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    It's not stored in the database. It's not so straightfowrward to do for that one instance, but if you want to change the word Event etc. add this to your functions.php

    //Rewrite any gettext field
    function my_em_text_rewrites($translation, $orig, $domain) {
    	switch ($orig) {
    		case 'Events' :
    			$translation = 'your text here';
    			break;
    		case 'events' :
    			$translation = 'your text here';
    			break;
    		//add this for further translations, including singular/plural variations
    	}
    	return $translation;
    }
    add_action ( 'gettext', 'my_em_text_rewrites', 1, 3 );

    otherwise, you should hook into the wp admin bar and change it that way (or if using BP, modify the $bp global)

  17. omegacoder
    Member
    Posted 2 years ago #

    I tried the code, but it doesn't work. Nothing happens

    The events manager plugin seems to integrate ok with buddypress, but when trying the translations, this particular word is difficult to source and change for other languages. You do know I'm refering to the events tab on the group details page right? Events manager will add a "Events" link next ot the other links like this:

    Home Forum Events 0 Members 2 Member Groups

  18. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    the above would rewrite any use of

    __('Events','dbem');
    __('events','dbem');

    if you want to replace sentences, you'd use something like:

    //Rewrite any gettext field
    function my_em_text_rewrites($translation, $orig, $domain) {
    	$translation = str_replace('Event','yourstring',$translation);
    	//etc.
    	return $translation;
    }
    add_action ( 'gettext', 'my_em_text_rewrites', 1, 3 );
  19. omegacoder
    Member
    Posted 2 years ago #

    thanks, I tried this and it worked.

    some of the translations are a bit more involved. When I view the events personal menu under "my events" link http://www.XXX.com/members/admin/events/my-events:

    My Profile
    Events I'm Attending
    My Events
    My Locations
    My Event Bookings

    How would I translate these? After applying the suggestions above I've got:

    个人资料
    活动 I'm Attending
    My 活动
    我的活动地点
    我的活动预订

    My 活动
    Add New
    Upcoming (0) | Pending (0) | Past 活动

    So how could I translate for example: 活动 I'm Attending into the full chinese text?

  20. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    Assuming this is our plugin doing the translating, this might be because of an incomplete chinese translation, you'd need to update the po files.

    Someone submitted an updated zh_CN translation which should be up to date so it'll be out in the next update, maybe that'll fix it for you.

  21. omegacoder
    Member
    Posted 2 years ago #

    yes, I am using an incomplete chinese translation, but I should still beable to modify the .pot file which i tried without success

    if a new updated and complete translation file is available in Chinese, that would surely make things alot more easier. Currently I've had to manage alot of the translations using the above hack with feels very wrong and is definitely a bad working solution. Anyway as long as it gets the job done that would have to suffice for now.

    Importantly; If you have any advice as to my previous post (the one with: So how could I translate for example: 活动 I'm Attending into the full chinese text?), then please let me know otherwise, thanks for your help thus far which I really appreciate

  22. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    I'll be releasing a dev update (looking like tomorrow morning now) that'll have this updated translation, I'm pretty sure that'll fix the incomplete translation you're mentioning.

    If not, let us know and we'll look at it then.

  23. omegacoder
    Member
    Posted 2 years ago #

    this is great news! Where can I go to get the dev update? What URL? Is the Chinese translations released as of this message post?

    I'm guessing we're from different international time zones. My time is Beijing time (GMT+8 hours)

  24. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    Yeah, I'm in Spain, CET so good evening :)

    I just released a dev version, which you can update to by going to Events > Settings > Admin Tools > Check Dev-Version (then visit your plugins page and refresh a couple time to see the update 5.2.9.2)

  25. omegacoder
    Member
    Posted 2 years ago #

    can I update on my test site, then just copy/paste the .op, .mo files to my live version?

    the word "dev" makes me nervous, and everytime I update a critical plugin on the live site, you know my heart pounds faster! ha ha!

  26. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    :) in this case dev should be fine. We make lots of incremental changes but normally nothing major, and we have our own internal SVN aside from the wp svn so devs available to you are somewhat-tested versions in between stables.

  27. omegacoder
    Member
    Posted 2 years ago #

    I've just followed your instructions, but I see no option to update to dev version 5.2.9.2

    I got the message:

    There is a new version of Events Manager available. View version 5.3 details or update now.

    I'm using multisite by the way, events manager plugin is installed on network. I've set the enable dev version from the events settings tab on network dashboard

  28. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    We updated to 5.3 during that time, so just update to that version.

  29. omegacoder
    Member
    Posted 2 years ago #

    I've updated to version 5.3 and I've checked the chinese translation .po file and it does contain the translations I need. However, the events manager plugin text on my website is still in english. My other plugins are displaying in chinese including buddypress, some custom plugins etc, so it's just events manager plugin translations that is giving me problems

    I've been trying several things including:

    regenerating the .mo file
    making sure the plugin domain is 'dbem' in my translations (although I don't believe I need to change any of this since they are from events manager 5.3 as is the .op, .mo files

    do you know what could be the issue causing this?

  30. omegacoder
    Member
    Posted 2 years ago #

    I've discovered that the qTranslate plugin I'm using is causing the problem.

    when i visited the url:
    http://www.mywebsite.com/zh/members/admin/events/my-events/?action=edit
    it works, however, when I use the proper url on my subsite:
    http://www.mywebsite.com/cn/members/admin/events/my-events/?action=edit
    the chinese translation don't work
    using
    http://www.mywebsitecom/cn/zh/members/admin/events/my-events/?action=edit
    works also

    When I disable the qTranslate plugin then the chinese translation works. I find this strange since my other plugins language files work fine qTranslate activated, but events manager language translation seem to get intefered with qTranslate activated. So all along qTranslate was giving me problems in what should be a simple use of .po, .mo translation files!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Events Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.