Skip to:
Content
Pages
Categories
Search
Top
Bottom

Translation fails only at "Sitewide Activity"

Viewing 13 replies - 1 through 13 (of 13 total)
  • Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    Did you use poedit?

    Did you include _x in Sources Keywords?

    I don’t know why _x is used for ‘Sitewide Activity’.
    You can see it in bp-activity\bp-activity-loader.php ~L. 109

    Avatar of wpleo
    wpleo
    Participant

    @wpleo

    Thank you @shanebp!

    You’re right, I found this strange _x. But it didn’t make the translation work for me.

    I got this bp-custom.php:

    define( ‘BPLANG’, ‘pt-br’ );
    if ( file_exists( WP_LANG_DIR . ‘/buddypress-’ . BPLANG . ‘.mo’ ) ) {
    load_textdomain( ‘buddypress’, WP_LANG_DIR . ‘/buddypress-’ . BPLANG . ‘.mo’ );
    //echo “FOUND IT!!”;
    }

    I’m pretty sure that this fil is being read and that the language file is being found because of the flag that I put: “FOUND IT!!”. In fact everything is being translated but the titles! No title got the proper translation, like:

    http://astronomia.blog.br/forum-astronomia/atividades/ (Sitewide Activity)
    http://astronomia.blog.br/forum-astronomia/pessoas/ (Members)
    http://astronomia.blog.br/forum-astronomia/grupos/ (Groups)

    Each one of these expressions is translated in the .po and .mo, acording to Loco Translate.

    Already deleted the pages and re-created it but nothing.

    I’m still trying, if I find a solution I’ll post it here.

    Thanks for the help!

    Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    You can always submit a ticket at

    https://buddypress.trac.wordpress.org/

    Avatar of wpleo
    wpleo
    Participant

    @wpleo

    That’s perfect!
    Thank you shanebp.

    Avatar of DarioZ
    DarioZ
    Participant

    @darioz

    DId you find any solution to this? I have the same problem.

    Avatar of wpleo
    wpleo
    Participant

    @wpleo

    Not yet @DarioZ.

    It seems to be a huge bug, because lots of people have this issue and no real solution can be found. I don’t want to give up BP, so I have my website running with this problem in translation.

    If you find something, please share here. I’ll certainly do the same.

    Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    You need to add this:

    _x:1,2c

    To Catalog Properties > Sources keywords in PoEdit.

    This is due to the use of the ‘context’ parameter for some titles via ‘_x’

    For example, the second element is the context parameter:
    _x( 'Sitewide Activity', 'component directory title', 'buddypress' )

    Make sure your Sources Keywords has at least these entries:

    _
    _()
    __
    __()
    _x:1,2c

    I use this approach and can change titles like ‘Sitewide Activity’

    Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    Just fyi – if you only have a few labels that you want to change, you can use these functions.

    http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
    http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext_with_context

    It’s a lot faster than messing with .po files.
    But you need to know if the label is using a context parameter.

    So you can use this approach for ‘Sitewide Activity’…

    function example_gettext_with_context( $translated, $text, $context, $domain ) {
    
      if ( 'buddypress' !== $domain )  
            return $translated; 
            
      switch ( $text ) {
    
            case 'Sitewide Activity':
                return 'Bongos';		
    	
            default:
                return $translated;
        }
    
        return $translated;
    }
    add_filter( 'gettext_with_context', 'example_gettext_with_context', 11, 4 );
    Avatar of danbp
    danbp
    Participant

    @danbp

    @wpleo,

    i checked the buddypress-pt_BR.po/mo. Sitewide Activity is correctly translated.
    I also added all gettext filters to the po, as mentionned by @shanebp
    without any result.
    I also tested with mesocolumn theme and magazine theme, with no result.

    The only solution for the moment is to change the original code to the old style way of translating a string ( __(”,”) )

    the string is in bp-activity-loader.php:109

    Change
    ‘directory_title’ => _x( ‘Sitewide Activity’, ‘component directory title’, ‘buddypress’ ),
    to
    ‘directory_title’ => __( ‘Sitewide Activity’, ‘buddypress’ ),

    will resolve the problem.

    Avatar of danbp
    danbp
    Participant

    @danbp

    @shanebp,
    forcing a translation is not the best solution, even if it is a solution.
    Mine by hacking the core file is not better, as we loose it at the next update.
    Your function won’t be loosed, but it should be used by caution, as gettext pass a second time on ALL strings. It’s not dramatical to force the translation for one string, but what will happen if someone use this trick for 20, 50 or more strings ? Performance trouble !

    I’ll track this further before opening a ticket.

    http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext

    http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext_with_context

    Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    >I also added all gettext filters to the po …without any result.

    Odd, simply adding _x:1,2c to Sources keywords in poedit works perfectly for myself and other devs.

    If you open a ticket, please mention this discrepancy in results.

    Avatar of danbp
    danbp
    Participant

    @danbp

    it’s not the theme
    it’s not the translation
    seems to be somthing unstable with bp-loader
    sometimes i have things translated, sometimes not ! Stuning ! :evil:

    Avatar of danbp
    danbp
    Participant

    @danbp

Viewing 13 replies - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.