Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gokberkbar/locale_plus
LocalePlus allows easy access to native device locale data in Flutter apps. Includes language, country code, time zone, and number formatting preferences.
https://github.com/gokberkbar/locale_plus
dart flutter flutter-android-ios flutter-app flutter-package locale pubdev
Last synced: about 21 hours ago
JSON representation
LocalePlus allows easy access to native device locale data in Flutter apps. Includes language, country code, time zone, and number formatting preferences.
- Host: GitHub
- URL: https://github.com/gokberkbar/locale_plus
- Owner: gokberkbar
- License: mit
- Created: 2023-01-04T12:52:16.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-06T18:46:47.000Z (5 months ago)
- Last Synced: 2024-06-06T20:38:09.142Z (5 months ago)
- Topics: dart, flutter, flutter-android-ios, flutter-app, flutter-package, locale, pubdev
- Language: Dart
- Homepage: https://pub.dev/packages/locale_plus
- Size: 187 KB
- Stars: 25
- Watchers: 2
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
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](#overview)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Author](#author)
- [Contributors](#contributors)
- [LICENSE](#license)# 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.0.0 <4.0.0"
- Flutter: ">=3.10.0"
- Android: minSdkVersion 16
- iOS 9.0+# 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: ^1.6.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.```Dart
import 'package:locale_plus/locale_plus.dart';Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await PatchAllLocales.patchNumberSeperators(
shouldPatchForSamsungKeyboard: true,
);
runApp(const MyApp());
}
```## Get if the user is using a samsung keyboard
```Dart
final decimalSeparator = await LocalePlus().isUsingSamsungKeyboard();
```## Get Decimal & Grouping Separator
```Dart
final decimalSeparator = await LocalePlus().getDecimalSeparator();
final groupingSeparator = await LocalePlus().getGroupingSeparator();
```## Get Language & Region Code
```Dart
final regionCode = await LocalePlus().getRegionCode();
final languageCode = await LocalePlus().getLanguageCode();
```## Get Seconds from GMT
```Dart
final secondsFromGMT = await LocalePlus().getSecondsFromGMT();
```## Is Device Using 24 hour time and Current Locale AM PM Symbols
```Dart
final is24HourTime = await LocalePlus().is24HourTime();
final amSymbol = await LocalePlus().getAmSymbol();
final pmSymbol = await LocalePlus().getPmSymbol();
```## Is Device Using Metric System
```Dart
final usesMetricSystem = await LocalePlus().usesMetricSystem();
```## Get TimeZone Identifier
```Dart
final timeZoneIdentifier = await LocalePlus().getTimeZoneIdentifier();
```## Get First Day Of Week
```Dart
final firstDayOfWeek = await LocalePlus().getFirstDayOfWeek();
```# Author
[Gökberk Bardakçı](https://www.github.com/gokberkbar), [Uygar İşiçelik](https://www.github.com/uygar)
# Contributors
[Bent Engbers](https://github.com/BentEngbers), [Renat Shakhmatov](https://github.com/shushper), [Giovanni Lattanzio](https://github.com/giovannilattanziocrispy), [Gökhan Çavuş](https://github.com/gokhancvs)
# License
LocalePlus is available under the MIT license. See the LICENSE file for more info.