Skip to:
Content
Pages
Categories
Search
Top
Bottom

Translation fails only at "Sitewide Activity"

Viewing 13 replies - 1 through 13 (of 13 total)
  • Profile photo of shanebp
    shanebp
    Moderator

    @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

    Profile photo 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!

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    You can always submit a ticket at
    https://buddypress.trac.wordpress.org/

    Profile photo of wpleo
    wpleo
    Participant

    @wpleo

    That’s perfect!
    Thank you shanebp.

    Profile photo of DarioZ
    DarioZ
    Participant

    @darioz

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

    Profile photo 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.

    Profile photo of shanebp
    shanebp
    Moderator

    @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’

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

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

    https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
    https://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 );
    Profile photo of danbp
    danbp
    Moderator

    @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.

    Profile photo of danbp
    danbp
    Moderator

    @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.

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

    Profile photo of shanebp
    shanebp
    Moderator

    @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.

    Profile photo of danbp
    danbp
    Moderator

    @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 ! 👿

    Profile photo of danbp
    danbp
    Moderator

    @danbp

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Translation fails only at "Sitewide Activity"’ is closed to new replies.
Skip to toolbar