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
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;
}
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?
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'){
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;
}
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
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.
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?
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
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.
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
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).
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
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
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...