From 74d768f7a5b8ad8951ee14363ae70281266016c2 Mon Sep 17 00:00:00 2001 From: Barry Ceelen Date: Wed, 20 Sep 2017 13:09:32 +0200 Subject: [PATCH] Use site language when loading Google Maps API --- fields/class-cmb-gmap-field.php | 2 ++ js/field-gmap.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fields/class-cmb-gmap-field.php b/fields/class-cmb-gmap-field.php index ecab0fcf..5e610b4f 100644 --- a/fields/class-cmb-gmap-field.php +++ b/fields/class-cmb-gmap-field.php @@ -34,6 +34,7 @@ public function get_default_args() { 'string-marker-title' => esc_html__( 'Drag to set the exact location', 'cmb' ), 'string-gmaps-api-not-loaded' => esc_html__( 'Google Maps API not loaded.', 'cmb' ), 'google_api_key' => '', + 'language' => explode( '_', get_locale() )[0], ) ); } @@ -68,6 +69,7 @@ public function enqueue_scripts() { 'markerTitle' => $this->args['string-marker-title'], 'googleMapsApiNotLoaded' => $this->args['string-gmaps-api-not-loaded'], ), + 'language' => $this->args['language'], ) ); } diff --git a/js/field-gmap.js b/js/field-gmap.js index 30e8dade..b8baad3f 100644 --- a/js/field-gmap.js +++ b/js/field-gmap.js @@ -100,6 +100,6 @@ CMB.addCallbackForClonedField( ['CMB_Gmap_Field'], CMBGmapsInit ); }; - $.getScript( '//maps.google.com/maps/api/js?sensor=true&libraries=places&callback=CMB_CMAPS_INIT&key=' + CMBGmaps.key ); + $.getScript( '//maps.google.com/maps/api/js?sensor=true&libraries=places&language=' + CMBGmaps.language + '&callback=CMB_CMAPS_INIT&key=' + CMBGmaps.key ); }(jQuery));