搜尋套件、儲存庫與 APP 分類

套件詳情v2.0.0

locale_plus

LocalePlus 可讓 Flutter 應用程式輕鬆存取原生裝置的地區設定資料。包含語言、國家代碼、時區與數字格式化偏好。

AndroidiOS
近 30 天下載
6520
喜歡數
33
Pub 分數
140

安裝套件

flutter pub add locale_plus

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

LocalePlus 是一個 Flutter 套件,可提供對原生裝置地區設定資訊的無縫存取,包含語言、國家代碼、時區與數字格式化偏好。它透過不需要複雜設定即可取得系統層級的地區設定資料,簡化了本地化流程。適用於需要精確地區設定以動態呈現內容、顯示日期/時間及貨幣格式化的應用程式。此套件與 Flutter 的國際化框架順暢整合,並支援 Android 與 iOS 平台。

適用情境

  • 基於用戶區域的動態介面
  • 顯示本地化日期和時間
  • 格式化數字和貨幣
  • 支援多語言應用
  • 透過區域設定調整應用程式行為
  • 透過區域設定增強可訪問性

主要特色

  • 獲取設備原生區域設定資料
  • 支援語言、國家、時區和格式化
  • 簡單的 API,設定簡單
  • 跨平台(Android 與 iOS)
  • 輕量且無依賴
  • 自動檢測使用者的首選語言環境

適合對象

  • 需要區域定制的應用程式
  • 國際化應用程式
  • 金融或旅行應用
  • 具有本地化需求的面向用戶的應用程式
  • 尋求快速區域設定訪問的開發者
  • 使用 Flutter 國際化功能的專案

使用建議

  • 依賴設備系統設定
  • 不處理翻譯字串
  • 僅限讀取區域設定資料
  • 無內建回退機制
  • 需要手動處理區域設定變更
  • 單獨使用不適合完整的國際化工作流程

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Locale Plus

LocalePlus allows easy access to native device locale data in Flutter apps. Includes language, country code, time zone, and number formatting preferences.

Table of Content

Overview

LocalePlus is a Flutter package that allows developers to easily retrieve data from the native device locale settings. With LocalePlus, developers can access information such as the device's language, country code, and time zone, as well as the device's number formatting preferences such as grouping and decimal separator. This makes it easy to build internationalized apps that provide a personalized experience for each user. Whether you're building a financial app that needs to display numbers in the user's local format or a social media app that needs to display timestamps in the user's time zone, LocalePlus has you covered. With a simple and intuitive API, LocalePlus is the perfect tool for any Flutter developer looking to add localization to their app.

Requirements

  • Dart sdk: ">=3.10.0 <4.0.0"
  • Flutter: ">=3.38.0"
  • Android: minSdkVersion 16
  • iOS 13.0+

The iOS plugin supports both Swift Package Manager and CocoaPods.

Installation

with Flutter:

$ flutter pub add locale_plus

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  locale_plus: ^2.0.0

Usage

Patch the locales with the users' group and decimal seperators

This function patches all locales in flutter, so that you can use the decimal seperator and group seperator from numberFormatSymbols after the patch is complete. The patchNumberSeperators function patches the locales on android and ios. The shouldPatchForSamsungKeyboard can be enabled, to patch for Samsung keyboards on android phones (they only allow for a . as input). It is safe to call on MacOS, Windows, Linux and web, but it does not patch the locales.

import 'package:locale_plus/locale_plus.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await PatchAllLocales.patchNumberSeperators(
    shouldPatchForSamsungKeyboard: true,
  );
  runApp(const MyApp());
}

Get if the user is using a samsung keyboard

final decimalSeparator = await LocalePlus().isUsingSamsungKeyboard();

Get Decimal & Grouping Separator

final decimalSeparator = await LocalePlus().getDecimalSeparator();
final groupingSeparator = await LocalePlus().getGroupingSeparator();

Get Language & Region Code

final regionCode = await LocalePlus().getRegionCode();
final languageCode = await LocalePlus().getLanguageCode();

Get Seconds from GMT

final secondsFromGMT = await LocalePlus().getSecondsFromGMT();

Is Device Using 24 hour time and Current Locale AM PM Symbols

final is24HourTime = await LocalePlus().is24HourTime();
final amSymbol = await LocalePlus().getAmSymbol();
final pmSymbol = await LocalePlus().getPmSymbol();

Is Device Using Metric System

final usesMetricSystem = await LocalePlus().usesMetricSystem();

Get TimeZone Identifier

final timeZoneIdentifier = await LocalePlus().getTimeZoneIdentifier();

Get First Day Of Week

final firstDayOfWeek = await LocalePlus().getFirstDayOfWeek();

Get Date format pattern

final dateFormatPattern = await LocalePlus().getDateFormatPattern();

Author

Gökberk Bardakçı, Uygar İşiçelik

Contributors

Bent Engbers, Renat Shakhmatov, Giovanni Lattanzio, Gökhan Çavuş

License

LocalePlus is available under the MIT license. See the LICENSE file for more info.

所屬分類

依賴

依賴清單 3 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。