react-google-places-autocomplete icon indicating copy to clipboard operation
react-google-places-autocomplete copied to clipboard

Create ability of changing language request for the utilities

Open rtatarinov opened this issue 2 years ago • 2 comments

Hello. Thank you for your library. It works great. But there is one problem. I use it in my application the next way:

import GooglePlacesAutocomplete, { geocodeByPlaceId } from "react-google-places-autocomplete";

export const Component = () => {
    const handlePickAddress = useCallback(
        async (result: any, field: "from" | "to") => {
            ......

            try {
                const data = await geocodeByPlaceId(result.value.place_id);
                
                 ...
            } catch (e) {}
        },
        [],
    );


   return  (
     <GooglePlacesAutocomplete
          apiKey={GoogleApiKey}
          apiOptions={{
              language: userLocale,
         }}
     />
  )
}

And I need to use geocodeByPlaceId and GooglePlacesAutocomplete with different languages. For example user uses autocomplete with spanish language, but geocodeByPlaceId uses english version. It need to save to database only English name of place id.

But for now after initialization GooglePlacesAutocomplete with particular language I can't to replace it. So can you create a functionality of changing language and other params for utils, as geocodeByPlaceId, etc.?

rtatarinov avatar Jan 26 '23 21:01 rtatarinov

I was just about to create an issue requesting the same. Can we add localization for this?

carteja avatar Feb 15 '23 19:02 carteja

I'm not sure about the geocodeBy* utilities, but for the autocomplete you can set the language on the autocompletion request (see here).

Tintef avatar Apr 17 '23 13:04 Tintef