Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting to override the Google API language #18

Merged
merged 1 commit into from Mar 15, 2021

Conversation

carlcs
Copy link
Contributor

@carlcs carlcs commented Mar 12, 2021

This allows to force a language that is used for the Google API calls. When the setting is not set, Google API continues using the browser language.

https://developers.google.com/maps/documentation/javascript/localization

Our use case for this setting is to get consistent lookup results in address fields for all users. Currently with Google Maps plugin we’re getting, for example, “Germany” for country address part when a user has the browser setup in English and “Deutschland” for users with a German browser.

In Smart Map we were always getting English results, because request were made from the server instead of the browser.

@carlcs
Copy link
Contributor Author

carlcs commented Mar 15, 2021

Hi @lindseydiloreto, I cleaned up the PR a bit, and fixed the issue where it wasn’t possible to override the API language by passing in the parameter to ApiHelper::getApiUrl(). I also did a rebase ontop of the latest version.

@lindseydiloreto
Copy link
Collaborator

Hey @carlcs, thanks for this! For the most part, it all looks great. Thanks for even going back and cleaning up the loose ends.

My only disagreement is in where the language is being stored... In my opinion, each language override should be handled separately, at the field level. So instead of having a sitewide language specification, each Address field could individually have a separate language.

There may be some weird edge cases where people want different Address fields to operate in different languages. I also want to avoid any confusion that the Google Maps plugin would be handling the language of front-end maps (because it won't).

I'll accept this PR and make a few tweaks. I plan on moving the language setting to the field level, which will of course require some UI adjustments. Feel free to use your forked version until the proper fix is in place (hopefully within 2-4 weeks)!

Thanks again! 🍺

@lindseydiloreto
Copy link
Collaborator

Just a heads up, a variation of this has been formally added in v4.0.5! 👍

You were right about needing to make this a global setting, it couldn't possibly be localized to each individual Address field. All Address fields share the same Google API URL, which is where those parameters need to be applied. So regardless of where it is stored in the plugin, that info can only be loaded once per page.

Thanks for putting in the hard work to get an initial version going! Let me know if you have any questions about the final implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants