Skip Navigation

[Resolved] Translation for error strings

This support ticket is created 4 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 10 replies, has 2 voices.

Last updated by Luo Yang 4 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#1776189

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

#1776753

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/

#1776785

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.

#1776801

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

#1776805

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

#1776809

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);
#1776907

My issue is resolved now. Thank you!

#1777369

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 🙁

#1778097

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

#1779879

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

#1780809

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