Skip Navigation

[Resolved] Translating buttons

This support ticket is created 8 years 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.

Our next available supporter will start replying to tickets in about 0.17 hours from now. Thank you for your understanding.

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 19 replies, has 2 voices.

Last updated by Luo Yang 7 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#408958

Hi there,

2 months ago we asked how to translate our buttons to dutch.
Outcome was that it was fixed in next release but it still isn’t:
https://toolset.com/forums/topic/localize-buttons-cred-wont-work/

We just want the buttons to be in dutch, we don't want to install WPML because it's crashing our site on activation and we just want a single language website (NL).

We tried the code from this post which seemed to do the trick:
https://toolset.com/forums/topic/how-to-translate-the-clear-button/

What codes do we need to translate this way for the next buttons:

image uploader:
- 'delete' button
- 'restore original' button

date picker (repetitive):
- 'add new data' button
- 'delete data repetition’ button

date picker
- 'delete date’ button

Thanks,

Paul

#409149

Dear Paul,

You can modify your PHP codes as below:

add_filter( 'gettext', 'clear_button_func', 20, 3 );
/**
 * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
 */
function clear_button_func( $translated_text, $text, $domain ) {
    if($domain = 'wpv-views'){
		if($text == 'Clear'){
			$translated_text = "Clear NL";
		}
		if($text == 'delete'){
			$translated_text = "delete NL";
		}
		if($text == 'Restore original'){
			$translated_text = "Restore original NL";
		}
		if($text == 'Delete'){
			$translated_text = "Delete NL";
		}
		if($text == 'Add new %s'){
			$translated_text = "Add new NL %s";
		}
    }
    return $translated_text;
}
#409565
Schermafbeelding 2016-06-22 om 08.34.12.png

Hi Luoy,

Thanks a lot, we only mis:
- the second part of the delete data repetition button in the repetitive date section: 'Data repetition'
- and the word 'Data'

(see screenshot).

I've tried to duplicate the code rules for this text but this doesn't work.
Can you help out?

#409694

For the delete button, please try with CRED filter hook "toolset_button_delete_repetition_text", for example:

add_filter('toolset_button_delete_repetition_text', 'change_delete_text',10,3);
function change_delete_text($default_value,$field_data){
	if($default_value == 'Verwijeren Data repetition'){
		$default_value = 'Verwijeren Data repetition NL';
	}
	return $default_value;
}

And there is a mistake in my previous codes, please change this line from:
if($domain = 'wpv-views'){

To:
if($domain == 'wpv-views'){

#412337
Schermafbeelding 2016-07-01 om 10.15.25.png

Hi Luoy,

I have one button which needs to be translated: wot-date-clear button

The button says 'Leegmaken Date'
i want to change it to 'Verwijderen'

'Leegmaken' is translated already but 'Date' seems to be dynamic...

I tried to duplicate your code and modify it but this is not working:

add_filter('toolset_button_date_clear', 'change_clear_text',10,3);
function change_clear_text($default_value,$field_data){
if($default_value == 'Leegmaken Date'){
$default_value = ' Verwijderen ';
}
return $default_value;
}

#412852

Since it is a custom PHP codes problem, could you duplicate same problem in a test site, and fill below private detail box with login details and FTP access, also point out the problem page URL and CRED form URL, and where I can edit you PHP codes, I need a live website to test and debug, thanks

#414396

The original po file is in CRED plugin folder:
cred-frontend-editor\embedded\locale\orig\wp-cred.po

and you will need to follow wordpress document:
https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/
To translate the po file into mo files.

#414499

One folder higher there is a wp-cred-nl_NL.mo
And where can i find the .po for this?

It's needed to open our language otherwise we have to translate all field where only a couple are needed.

The wp-cred-nl_NL.mo file doesn't seem to do anything because the site is showing EN language.
How can this be arranged to use the NL language from this file?

#414917

Q1) And where can i find the .po for this?
There isn't wp-cred-nl_NL.po file within CRED plugin, you will need to translate it into your language manually from the original English file "wp-cred.po"
For example, you can use Poedit tool:
https://make.wordpress.org/polyglots/handbook/tools/poedit/

Q2) How can this be arranged to use the NL language from this file?
CRED is using wordpress function load_textdomain() to load the mo file translations, see the source codes of CRED plugin, file \plugins\cred-frontend-editor\embedded\toolset\toolset-common\inc\toolset.localization.class.php, line 53~57:

function load_textdomain() {
			$locale = get_locale();
			$this->mo_processed_name = sprintf( $this->mo_name, $locale );
			load_textdomain( $this->textdomain, $this->path . '/' . $this->mo_processed_name . '.mo' );
		}

More help:
Loads MO file into the list of domains.
https://codex.wordpress.org/Function_Reference/load_textdomain

#415365
3.png
1.png
4.png
2.png

Hi Luoy,

I think there is a issue there, we checked our settings and everything is set to NL:
- The language in WP settings is set to NL (see screenshot 1)
- We even inserted: define ('WPLANG', 'nl_NL') in wp-config (which is no longer necessary) (see screenshot 2)
- We checked the NL mo file of wp-cred which has the proper translation (see screenshot 3, term 'not set' - 'niet ingesteld')

And still it it's trowing up the EN mo file (see screenshot 4, term 'not set - should be: niet ingesteld').

What do i need to do?
We used a clean wp4.x install and the latest wp-types plugins.

All button translation would be fixed after a work mo file as well i think.

#415776

For the string "not set", which is in text domain "wp-cred", so your mo file should names as:
wp-cred-nl_NL.mo,

For other button string, for example:
string "Clear", which is in text domain name "wpv-views", so you will need translate them into mo file:
wpv-views-nl_NL.mo

And put them into CRED plugin folder:
\cred-frontend-editor\embedded\locale

#415780

Hi Luoy,

It is...
it's even there when wp-cred is installed, but it's not working.

We created the po file for that by a online converter because the po files are not there as well (in the standard wp-cred plugins folder). It would be a good idea to deliver the the translations in mo and po for wp-cred users.

The problem is not the existence of the file but the fact it's not working (in a standard wp-cred install).

#416220

What online converter are you using?
Could you duplicate same problem in a test site, and fill below private detail box with login details and ftp access, also point out the problem page URL, and which string do you want to translate, I need a live website to test and debug. thanks

#416517

Could you point out the problem page URL and the problem CRED form URL?
and which string do you want to translate?
It will help us to find the problem more quick, thanks

#417199

Hi Luoy,

The problem is in all forms.
We set up wordpress to NL but wp-types and wp-views seems to ignore these settings because it keeps showing the EN settings.

Dropdown menus are starting with 'not-set' which is the EN translation.

A sample you will find here:
hidden link

I think it's not a solution to create a temp fix, it would be better to have the toolset plugins work with the NL mo files.

------ Opinion mo/po:

Q1) And where can i find the .po for this?
There isn't wp-cred-nl_NL.po file within CRED plugin, you will need to translate it into your language manually from the original English file "wp-cred.po"

I think it's weird wp-types creates the po files but i have to do the complete translation over again for adjusting one field. It would be much easier to deliver the po files as well, i cannot see the problem to place these translated mo files in the install folder...

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.