hello, please help to find how i can translate some string in my page to my language (Ukrainian) i use Astra theme, and block editor. For example i create login page but when string must be "nickname or email" i see wrong text "link for lost password" on other language hidden link
And how i can use condition for show or not show some information (heading, texts or other field) by user role (in same screenshot)
thank for help
What is the link to your site? hidden link
Hello,
Q1) I can duplicate the same problem in my localhost, and have escalated this issue.
Currently, you can use gettext filter to change the translation, for example, add below PHP codes into your theme file functions.php:
add_filter('gettext', function($trasnlated, $text, $domain){
if($text == 'Username or Email' && $domain == 'wpv-views'){
$trasnlated = 'Username or Email in Ukrainian';
}
return $trasnlated;
}, 10, 3);
Q2) I suggest try with Toolset Access plugin, use shortcode [toolset_access] to display different content for different user role:
https://toolset.com/course-lesson/access-control-texts-inside-page-content/
Hello, Luo Yang
I have many error strings in language as i need, can I add other string to this function and how, if it possible?
I'll copy from plugins (toolset-blocks, types-access, cred-frontend-editor, types ) in language folders original .po files and in poedit edit/made views-uk.mo file but i don't sure they are can lost my translations after update.
About q2 - Thank you for documentation link. I'm sorry for this question I can't sometimes formulate the correct keywords for search.
I suggest you feedback for those wrong translation, create different ticket for each plugin, so we can fix the issues, and provide the workaround for you, thanks
ok i'll try make note for each plugins with error strings in my language and i can in feature provide right .mo files for you company if you assist me how i can do it right for you.
What about how to add in your function.php other wrong string (i need add 5-10 on first time)
Thank you
You can add more translation in the custom PHP codes I provided above, for example:
add_filter('gettext', function($trasnlated, $text, $domain){
if($text == 'Username or Email' && $domain == 'wpv-views'){
$trasnlated = 'Username or Email in Ukrainian';
}
if($text == 'OTHER TEXT' && $domain == 'wpv-views'){
$trasnlated = 'OTHER TEXT in Ukrainian';
}
if($text == 'OTHER TEXT 2' && $domain == 'wpv-views'){
$trasnlated = 'OTHER TEXT 2 in Ukrainian';
}
return $trasnlated;
}, 10, 3);
My issue is resolved now. Thank you!
Lou Yang i'm sorry i find string "1 Comment" how i need write in function for translate this string. With string "No comment" everything all right 🙁
Which plugin are we talking about? Where does the "1 Comment" come from?
Please provide detail steps to duplicate the same problem, I need to test it in my localhost, thanks
Sorry for my delay
I mean, when I use in "Fields and Text" shortcode [wpv-post-comments-number] in single case (no comments) translate in function is work, but if have comment (1 or more - dynamic number) translate in function is not work hidden link.
Thank you
Thanks for the details, for the shortcode [wpv-post-comments-number], you can setup those text in shortcode attributes, for example:
[wpv-post-comments-number none='No Comment in Ukrainian' one='1 Comment in Ukrainian' more='% Comments in Ukrainian']
See our document:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-153457