Skip Navigation

[Resolved] Translate “Use my location” message on cred form

This thread is resolved. Here is a description of the problem and solution.

Problem:

I need to translate "Use my location" message on cred form, when i use an address field with google map. I don´t use WPML. Can i use a code in functions.php to translate

Solution:

You can translate the "Use my location" message with WordPress built-in filter hook gettext, for example, add below codes into your theme file functions.php:

add_filter( 'gettext', 'my_text_func', 20, 3 );
/**
 * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
 */
function my_text_func( $translated_text, $text, $domain ) {
    if($text == 'Use my location' && $domain = 'toolset-maps'){
        $translated_text = "Use my location in your language";
    }
    return $translated_text;
}

Relevant Documentation:

https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. 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)

This topic contains 2 replies, has 2 voices.

Last updated by selmoK 6 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#873805

Hi,

I need to translate "Use my location" message on cred form, when i use an address field with google map. I don´t use WPML. Can i use a code in functions.php to translate, please?

#875065

Hello,

You can translate the "Use my location" message with WordPress built-in filter hook gettext, for example, add below codes into your theme file functions.php:

add_filter( 'gettext', 'my_text_func', 20, 3 );
/**
 * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
 */
function my_text_func( $translated_text, $text, $domain ) {
    if($text == 'Use my location' && $domain = 'toolset-maps'){
        $translated_text = "Use my location in your language";
    }
    return $translated_text;
}
#875330

It worked fine!

Thank you!