Translation fails only at "Sitewide Activity"
-
I got this page http://astronomia.blog.br/forum-astronomia/atividades/ that is the page with Sitewide Activity.
This phrase is the only one that does not appear translated. I checked with the plugin Loco Translate, and it is translated in the pt_BR file, but, for some reason, it doesn’t work. Everything eles does, aparently.
Any ideas?
-
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. 109Thank 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!
You can always submit a ticket at
https://buddypress.trac.wordpress.org/That’s perfect!
Thank you shanebp.DId you find any solution to this? I have the same problem.
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.
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’
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_contextIt’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 );
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.
@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>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.
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 ! 👿Finally I opened a ticket !
- The topic ‘Translation fails only at "Sitewide Activity"’ is closed to new replies.