Baseflow / flutter-geocoding

A Geocoding plugin for Flutter
https://baseflow.com
MIT License
134 stars 69 forks source link

[Bug]: localeIdentifier not working in iOS #208

Closed tomasAlabes closed 4 months ago

tomasAlabes commented 4 months ago

Please check the following before submitting a new issue.

Please select affected platform(s)

Steps to reproduce

I believe this used to work recently.

final List<Placemark> placemarks = await placemarkFromCoordinates(
                52.36477, 4.88124,
                localeIdentifier: "en_US");

Expected results

{
      // ...
      "country": "Netherlands", 
}

Actual results

{
      // ...
      "country": "Nederland", 
}

Code sample

Code sample ```dart final List placemarks = await placemarkFromCoordinates( 52.36477, 4.88124, localeIdentifier: "en_US"); ```

Screenshots or video

No response

Version

2.2.0

Flutter Doctor output

Doctor output ```console Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.19.1, on macOS 14.3.1 23D60 darwin-arm64, locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2023.1) [✓] IntelliJ IDEA Ultimate Edition (version 2023.3.4) [✓] VS Code (version 1.86.2) [✓] Connected device (5 available) [✓] Network resources • No issues found! ```
Mohamed-Nagdy commented 4 months ago

I face the same issue in both android and iOS I provide the locale (ar) and it give me back the result in English

tomasAlabes commented 4 months ago

@TimHoogstrate @mvanbeusekom this was introduced in this PR: https://github.com/Baseflow/flutter-geocoding/pull/205

Version 2.2.0 breaks the localIdentifier feature. See geocoding.dart: https://github.com/Baseflow/flutter-geocoding/pull/205/files#diff-2b11c3984a637300869b693b92f909a812bfb0d028ead4d7959f2f90b4348bcb

@Mohamed-Nagdy, reverting to 2.1.1 "fixes" it.

TimHoogstrate commented 4 months ago

Dear @tomasAlabes, @Mohamed-Nagdy,

It is expected behaviour. Recently the functionality for Android has been changed. As shown below (from the CHANGELOG) the locale is now set via a separate method. 'setLocaleIdentifier'.

CHANGELOG Android

## 3.0.0

* **BREAKING CHANGES**:
  * Updates `geocoding_platform_interface` to version 3.1.0.
  * Adds method `setLocaleIdentifier` to set the locale for all calls to the geocoding platform.
  * Removes the `localeIdentifier` argument from all methods. Use method `setLocaleIdentifier` to configure the locale.
* Implements `placemarkFromAddress`.

The locale should be set separately from version 2.2.0 by:

 /// Sets the locale identifier used for the geocoding.
  ///
  /// The `localeIdentifier` should be formatted using the syntax:
  /// [languageCode]_[countryCode] (eg. en_US or nl_NL).
  Future<void> setLocaleIdentifier(
    String localeIdentifier,
  ) {
    throw UnimplementedError(
        'setLocaleIdentifier() has not been implementated.');
  }

HOWEVER, apparently the functionality was not properly updated on iOS. Therefore I made two PR's (1) (https://github.com/Baseflow/flutter-geocoding/pull/209) to update the functionality on iOS to make it in line with Android. (2) update the documentation (https://github.com/Baseflow/flutter-geocoding/pull/210).

Kind regard,