esbanarango / ember-place-autocomplete

Ember cli addon to provide a component that uses Google Places API to autocomplete place information when people write their address
MIT License
63 stars 62 forks source link

Dynamically change language #47

Closed byrnedo closed 7 years ago

byrnedo commented 7 years ago

I'm using i18n and would like to get the language changed here when it is changed in i18n (https://github.com/jamesarosen/ember-i18n).

You think that's possible?

Falibur commented 7 years ago

Hi,

When you use that plugin you can just set the attributes and it would work as expected? Like in the following example:

<label> <strong>{{t "settings.location-address.company-name"}}</strong> {{place-autocomplete-field value=businessName handlerController=this types="establishment" setValueWithProperty="name" placeholder=(t "settings.location-address.company-name-placeholder") placeChangedCallback="placeChanged"}} </label>

byrnedo commented 7 years ago

Hi, thanks for the reply, I meant more the language that will be used in the calls to the google api. It's a bit tricky since it's in the url for the script. I got around it by having a service fetch the script for a language and notify when it was downloaded.

dmuneras commented 7 years ago

Hey @byrnedo,

Thanks for taking the time to report this, and sorry for the late response. But @yratanov did it some time ago: https://github.com/dmuneras/ember-place-autocomplete/commit/a01bc9ac12adb79ec08c3fb5152b0c8f780f5d8e

In case you haven't found a solution of someone need it in the future:

You just have to pass the options in the environment configuration: config/environment and the region and language are going to be added to the script tag to request google places autocomplete.

  let ENV = {
    modulePrefix: 'dummy',
    environment,
    rootURL: '/',
    locationType: 'auto',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      },
      EXTEND_PROTOTYPES: {
        // Prevent Ember Data from overriding Date.parse.
        Date: false
      }
    },

    'place-autocomplete' : {
      language: 'en',
      region: 'GB'
    }

    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    }
  };

Best regards, Daniel.

dmuneras commented 7 years ago

@byrnedo I am going to close this question but feel free to reopen if needed.