Skip Navigation

[Resolved] Address field and site language

This support ticket is created 3 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: Africa/Casablanca (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by jaumeB 3 years, 3 months ago.

Assisted by: Jamal.

Author
Posts
#2172145

Hi!
The default and only language of the site I'm building is english. This site is gonna be used in Europe. Different countries with different languages. And we have an address custom field which contain is provided by customers (with a post form).
Depending on the browser language, this custom field has a different language (dutch, spanish, italian...) and we need it to be in english.

I've found this ticket from 2018: https://toolset.com/forums/topic/translate-address-field/
It seems it wasn't possible to fix the map language and that the Toolset Team was considering it as feature request.
I've search in the documentation, checked the toolset settings for maps... but I didn't find a way to indicate that the maps have to be in english.

In the Google documentation I've found a solution. If you want the map in japanese, you only have to call the API that way:
<script async
src="hidden link">
</script>

I've looked in Toolset Maps code and I've found a way to change the API call, but I don't like this solution because I will have to remember to change the line of code when the Toolset Maps plugin will be update.

It's in toolset-common-functions.js
function get_api_key($api_key = '')
{
$saved_options = $this->get_options();
return $saved_options['api_key'] . '&language=en';
}
As I said, I don't like this solution. So I've decided to write here for your help. Maybe there's an easy way and I didn't find it!
😉

Thank you very much!
Regards

#2172795

Hello and thank you for contacting Toolset support.

I searched through the Toolset Maps code and I couldn't really find a clean solution to this. I am adding this ticket to the feature request to increase the number of users asking it. Hopefully, this will increase its priority and we'll all get it in an upcoming release.

However, I found out the use of an undocumented filter toolset_filter_toolset_maps_get_api_key. You can use it instead of modifying the plugin's code. It is used in several places, so, you should better register it only for the frontend, or for the specific page where the form is used. Maybe, something like:

if ( ! is_admin() ) add_filter('toolset_filter_toolset_maps_get_api_key', 'my_hack_to_translate_the_map');
function my_hack_to_translate_the_map( $api_key ){
    return $api_key . '&language=en';
}

I hope this helps. Please, let me know what you will get.

#2174109

Hi Jamal!
Thank you very much!
I've found a very very easy way to add the region and language!!! In Toolset Maps settings, inside the field for de Google API key, I've wrote the key and the code suggested by Google.
So in the same field I have: GOOGLEMAPSAPIKEY&region=US&language=en
Regards!
Margarita