expo / expo

An open-source framework for making universal native apps with React. Expo runs on Android, iOS, and the web.
https://docs.expo.dev
MIT License
29.53k stars 4.69k forks source link

Localization languageTag missing region code #28519

Closed NilsBaumgartner1994 closed 2 weeks ago

NilsBaumgartner1994 commented 2 weeks ago

Minimal reproducible example

-

What platform(s) does this occur on?

Web

Did you reproduce this issue in a development build?

Yes

Summary

I get the output for the languageTag for germany "de" instead of "de-DE".

import {useLocales as useLocalesExpo} from "expo-localization";

function useDeviceLocaleCodesIn_IETF_BCP_47(): string[] {
    const locales = useLocalesExpo()
    let localeCodes: string[] = [];
    for (let i=0; i<locales.length; i++) {
        let locale = locales[i];
        //locale.languageCode; // e.g. "en"
        localeCodes.push(locale.languageTag); // "de" or "de-DE"
    }
    return localeCodes;
}
[
  {
    "languageTag": "de",
    "languageCode": "de",
    "textDirection": null,
    "digitGroupingSeparator": ".",
    "decimalSeparator": ",",
    "measurementSystem": null,
    "currencyCode": null,
    "currencySymbol": null,
    "regionCode": null,
    "temperatureUnit": null
  },
  {
    "languageTag": "en-US",
    "languageCode": "en",
    "textDirection": null,
    "digitGroupingSeparator": ",",
    "decimalSeparator": ".",
    "measurementSystem": null,
    "currencyCode": null,
    "currencySymbol": null,
    "regionCode": "US",
    "temperatureUnit": "fahrenheit"
  },
  {
    "languageTag": "en",
    "languageCode": "en",
    "textDirection": null,
    "digitGroupingSeparator": ",",
    "decimalSeparator": ".",
    "measurementSystem": null,
    "currencyCode": null,
    "currencySymbol": null,
    "regionCode": null,
    "temperatureUnit": null
  }
]

Environment

expo-env-info 1.2.0 environment info: System: OS: macOS 13.4.1 Shell: 5.9 - /bin/zsh Binaries: Node: 18.19.1 - ~/.nvm/versions/node/v18.19.1/bin/node Yarn: 1.22.21 - /usr/local/bin/yarn npm: 10.2.4 - ~/.nvm/versions/node/v18.19.1/bin/npm Watchman: 2023.11.27.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.14.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4 IDEs: Android Studio: 2023.1 AI-231.9392.1.2311.11076708 Xcode: 14.3.1/14E300c - /usr/bin/xcodebuild npmPackages: expo: ~50.0.17 => 50.0.17 expo-router: ~3.4.9 => 3.4.9 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 react-native: 0.73.6 => 0.73.6 react-native-web: ~0.19.6 => 0.19.10 npmGlobalPackages: eas-cli: 7.4.0 Expo Workflow: managed

Expo Doctor Diagnostics

✔ Check Expo config for common issues ✔ Check package.json for common issues ✔ Check native tooling versions ✔ Check dependencies for packages that should not be installed directly ✔ Check for common project setup issues ✔ Check for issues with metro config ✔ Check npm/ yarn versions ✔ Check Expo config (app.json/ app.config.js) schema ✔ Check that packages match versions required by installed Expo SDK ✔ Check for legacy global CLI installed locally ✔ Check that native modules do not use incompatible support packages ✔ Check that native modules use compatible support package versions for installed Expo SDK

Didn't find any issues with the project!

expo-bot commented 2 weeks ago

Hi there! It looks like your issue requires a minimal reproducible example, but it is invalid or absent. Please prepare such an example and share it in a new issue.

The best way to get attention to your issue is to provide a clean and easy way for a developer to reproduce the issue on their own machine. Please do not provide your entire project, or a project with more code than is necessary to reproduce the issue.

A side benefit of going through the process of narrowing down the minimal amount of code needed to reproduce the issue is that you may get lucky and discover that the bug is due to a mistake in your application code that you can quickly fix on your own.

Resources