패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.9.1

devicelocale

현재 장치에 정의된 로케일을 추출하는 데 사용할 수 있는 Flutter 패키지로, 현재 로케일이 목록의 첫 번째로 설정됩니다.

AndroidiOSWebmacOSLinux
30일 다운로드
12.9만
좋아요
151
Pub 점수
150

패키지 설치

flutter pub add devicelocale

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

devicelocale 패키지는 사용자 장치에 구성된 로케일 목록을 가져오는 Flutter 유틸리티로, 현재 시스템 로케일이 먼저 나타납니다. Android, iOS, Web, macOS, Linux 등 여러 플랫폼을 지원하여 로컬라이제이션 인식 기능이 필요한 애플리케이션에 적합합니다. 네이티브 장치 설정에 접근함으로써 수동 구성 없이 앱이 사용자 선호도에 동적으로 적응할 수 있게 해줍니다. 이 패키지는 가볍고 국제화 워크플로우에 원활하게 통합됩니다.

사용 사례

  • 다국어 앱에서의 동적 언어 감지
  • 시작 시 사용자 선호 언어 자동 선택
  • 장치 설정에 기반한 앱 로컬라이제이션 지원
  • 지역 인식 기능 구축
  • 시스템 설정과 UI 언어 동기화

주요 기능

  • 현재 로케일을 먼저 반환하고 장치 정의 로케일을 반환합니다
  • 주요 OS에서의 크로스 플랫폼 지원
  • 로케일 목록을 검색하는 간단한 API
  • Flutter의 로컬라이제이션 프레임워크와 통합됩니다
  • 경량이며 종속성 없음

적합한 대상

  • 글로벌 청중을 대상으로 하는 앱
  • 로컬라이제이션 중심 애플리케이션
  • Flutter의 intl 패키지를 사용하는 개발자
  • 자동 로케일 백업이 필요한 프로젝트
  • 반응형 국제화를 구현하는 팀

고려 사항

  • 기기의 기본 설정에 의존합니다
  • 사용자 지정 로케일 오버라이드를 처리하지 않음
  • 로케일이 설정되어 있지 않으면 빈 목록을 반환할 수 있습니다
  • 일부 시스템에서는 플랫폼별 권한이 필요합니다
  • 읽기만 가능하며 장치 로케일 설정을 수정할 수 없습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

devicelocale

Gets the device locale data, independent of the app locale settings.

Usage

import 'package:devicelocale/devicelocale.dart';

then

List languages = await Devicelocale.preferredLanguages;
String locale = await Devicelocale.currentLocale;

this should return a list of the preferred/current language locales setup on the device, with the current one being the first in the list or just the currently set device locale.

Android specific implementation (no-op on other platforms if supported)

Added per-app language preferences for Android (https://developer.android.com/about/versions/13/features/app-languages#kotlin) You can check if your current device is supported isLanguagePerAppSettingSupported And after checking if your device is supported you can set the per-app language preference with setLanguagePerApp(Locale) this will return true if success

Note for Linux

Since GNU/Linux and POSIX doesn't provide a standard API for getting the preferred languages, Devicelocale.preferredLanguages always returns the current locale.

Swift Package Manager (iOS / macOS)

Both CocoaPods and Swift Package Manager are supported; Flutter ≥ 3.44 uses SwiftPM automatically. To verify SwiftPM locally on Xcode 26+, clone the repository into a directory matching the pubspec name, otherwise the example app build fails with a SwiftPM identity-mismatch error (pub.dev users are unaffected):

git clone https://github.com/magnatronus/flutter-devicelocale.git devicelocale

Updates

Sept 2023

merged pull request for compatibility with AGP 8

Feb 2023

Added 2 new functions for this iOS issue

  • defaultLocale
  • defaultAsLocale
July 2022

Added support for per-app language preferences on Android (https://developer.android.com/about/versions/13/features/app-languages#kotlin) You can now set the per-app language if you have an in app language picker. Updated the demo app

May 2022

Merged pull requests

Oct 2021

Updated the code and APIs used by Flutter for an Android plugin - this was the source of the Deprecated API warning in the Android build.

July 2021

Add beta support for Linux

March 2021

Added test support for web

Updated for null safety

Jul 2020 Locale update v0.3.1

This is an update from a received request, where prior to 0.3.1 the 2 methods:

  • preferredLanguages
  • currentLocale

returned string values.

There are now 2 equivilent methods

  • preferredLanguagesAsLocales
  • currentAsLocale

that now also return a Locale object rather than a string.

releases
  • March 2021 1.0.0 Updated to null safety

  • July 2020 0.3.0 Updated Android to support Android Embedding V2

  • Apr 2020 0.2.3 Updated Android code from contributions from @ened

  • Mar 2020 0.2.2 Updated iOS so that if detected locale is null then it is not included in return value

  • Sep 2019 0.2.0 Updated Android following feedback from https://github.com/huzhirento . Fallback to the currentLocale when attempting to get a list of locales fro Android 7 and below as the getLocales() call is a feature of API 24 and failed for Android 7 and below.

Getting Started

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트