I am using the woocommerece plugin and I uploaded the hebrew translation. Everything work well and the extra translation I needed I did with the loco plug in. There is 1 word that stayed in english in the my account menu "addresses" and i don't know why it stayed there and canwt find it in the pot file to translate it. Does anyone has some idea for it?
I solved the problem with a code snippest I found in http://www.remicorson.com/.
The snippest show you how to translate a single word, I used it with the problematic word, and it worked!
// Translating single words
add_filter('gettext', 'translate_text');
add_filter('ngettext', 'translate_text');
function translate_text($translated) {
$translated = str_ireplace('ADDRESSES', 'כתובות', $translated);
return $translated;
}
Related
Does anyone know how to stop Google translate from translating just the currency symbol?
I have installed GTranslate to translate woocommerce site. It translates well - however it also translates the currency symbol from £ to Euro. I have serched and found many of the same answer to prevent the currency symbol from being translated.
It involves wrapping every £ sign with a span like, £ this is impractical, takes too long and may need to be removed at a later date.
I thought I would try via a filter in the functions file as mentioned on the woocommerce website (see below) However, it doesn't work - possibly Google is translating it after the filter?
add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
function change_existing_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'AUD': $currency_symbol = 'AUD$'; break;
}
return $currency_symbol;
}
Any help or suggestions woul dbe appreicated, I'm a bit stumped on this one.
Thnaks in advance
Am having a positive experience whilst using Gravity forms on Wordpress as a whole. However, I am adding a field mask to an input and encountering a small problem.
Every 16 digit account number starts 001191, and we want the customer to be able to input their account number (and not one of the few other identifying numbers associated with them!) into this form.
So, I have that (001191) as a placeholder and a custom mask like this:
0011919999999999
The trouble is, I would like to have that first 9 as part of the custom mask, but can't find a way of escaping it successfully.
I've tried using backslash before it, using quote marks and double quotes, but no joy so far.
Has anyone had a similar problem and found a neat way of resolving this, please?
Gravity Forms' uses this script to power our inputs masks (this will change in a future version; version at the time of writing is GF2.3).
https://github.com/digitalBush/jquery.maskedinput
You can add an HTML field to your form and setup a custom definition like so:
<script>
jQuery(function($){
$.mask.definitions['~']='[9]';
});
</script>
In this example, you would use '~' in your input mask to represent a literal 9.
Edit
If you want to override the default definition, something like this should work:
<script>
jQuery(function($){
delete $.mask.definitions['9'];
$.mask.definitions['n'] = '[0-9]';
});
</script>
Then you could use a literal 9 in your mask. The second line replaces the '9' definition with n so you can use n in your input mask to require a number 0 - 9.
Edit II (Nov 11, 2021)
GF 2.5 introduces some order-of-events changes that are challenging to work around. The easiest way to do this now is to reinitialize your mask after overriding the preset definitions.
delete $.mask.definitions['9'];
$.mask.definitions['n'] = '[0-9]';
$( '#input_{formId}_{fieldId}' ).mask( 'nn-99-aaa' );
There's definitely a way to avoid this but I don't have the time to dig in this morning. 😅
Currently using GravityForms 2.6.7, this solution references the 'gform_input_mask_script' function here: https://docs.gravityforms.com/gform_input_mask_script/ as well as reworking Dave from Gravity Wiz example above. This example is applied to more than one form field - ID 214 (example account number) and ID 175 (phone number field) and placed within function.php file:
add_filter( 'gform_input_mask_script_45', 'custom_validation_mask', 10, 4 );
function custom_validation_mask( $script, $form_id, $field_id, $mask ) {
$script = "jQuery(function($){
delete $.mask.definitions['9'];
$.mask.definitions['x'] = '[0-9]';
$('#input_45_214').mask( '9xxxxxxxxxxxZxxxxxxxxx' );
$('#input_45_175').mask( 'xxxxxxxxxx' ); });";
return $script;
}
I’ve been trying to get a Members Directory to sort by last name, but have had no luck. Any help would be much appreciated.
The directory is here: http://109.199.101.20/~newfeldenkrais/practitioner-search/results/
The search is powered by the plugin BP Profile Search, but is displaying on the default members page.
Versions:
WP – Version 4.7.5
BP – Version 2.8.2
BP Profile Search – Version 4.7.6
I’ve tried various solutions that I was able to find on Google with no luck, the most recent solution I could find was here: https://buddypress.org/support/topic/custom-searchfilter-based-on-custom-field/
It looks like that solution is looking for the space between the First Name and Last Name to target the last name, but BuddyPress seems to be grabbing the “nicename”, which has no space. So, it isn’t able to target the space for me?
Use this hook in functions.php,
public function alphabetize_by_last_name( $bp_user_query ) {
if ( 'alphabetical' == $bp_user_query->query_vars['type'] )
$bp_user_query->uid_clauses['orderby'] = "ORDER BY substring_index(u.display_name, ' ', -1)";
}
add_action ( 'bp_pre_user_query', 'alphabetize_by_last_name' );
Ref : https://gist.github.com/mgmartel/4463855
https://buddypress.org/support/topic/sort-user-list-by-last-name/
i am trying to translate my plugin options through WPML but it is not working.
Here is how i have placed my string in the plugin file
get_option(_e('my_label','my-text-domain'));
I have already scan my plugin through the WPML and have done translation in "German" while default is English.
Can anyone help me.
Thanks
The issue is that _e outputs the translated text.
You want __ (double underscore), which will return the translated text.
I would explore other solutions to this problem. In general you shouldn't be using translation to determine what option to pull from the database. The functionality of your plugin should not hinge on whether or not the translated text is a valid option name.
An alternative approach may be to use get_locale to fetch the current locale and then use that to determine the option name:
$option_name = get_locale() . 'my_label';
$label = get_option( $option_name );
Now you can still get the localized version of your option, without depending on translators to input the correct option name.
If you have to use the translation approach, I would use _x to explain that the translated text should be an option key.
get_option( _x('my_label', 'Must be a valid option name', 'my-text-domain') );
Provided that you have multiple entries in your meta table per language, try the double underscore function?:
get_option( __( 'my_label','my-text-domain' ) );
i am trying to auto register string in wordpress, but for some reason it doesn't work
it works when i call in the code of the theme:
esc_html_e('mytext','mythemename');
and then do
WPML->theme and plugins localization->strings in the theme->scan the theme for strings
then mytext appears in strings list for translation
but if i try instead to enable:
wpml->string translation->auto register strings for translation->auto-register strings always->apply
and in the code run, f.ex.:
$myvar='mytext';
esc_html_e($myvar,'mythemename');
then, of course, i go to wp page where string appears, but nothing happens, string doesn't get added to theme strings list
does anybody know if i am doing something wrong?
it started adding the strings when instead of esc_html_e i wrote:
icl_register_string('mythemename','myvariable',$myvar);
echo icl_t('mythemename','myvariable',$myvar );
i'm sure there is more elegant solution but since this one works it'll do for now.