https://github.com/rk0cc/intl_script_recognizer
Flutter to Intl locale resolver
https://github.com/rk0cc/intl_script_recognizer
date-format dateformat flutter intl locale locales localization script
Last synced: 3 months ago
JSON representation
Flutter to Intl locale resolver
- Host: GitHub
- URL: https://github.com/rk0cc/intl_script_recognizer
- Owner: rk0cc
- License: bsd-3-clause
- Created: 2023-05-10T07:39:00.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-11T14:16:42.000Z (over 2 years ago)
- Last Synced: 2025-08-17T16:45:22.795Z (6 months ago)
- Topics: date-format, dateformat, flutter, intl, locale, locales, localization, script
- Language: Dart
- Homepage:
- Size: 45.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# An adapter helps `intl` package recognize correct language when `Locale` specified script language
---
---
The pattern of locale for [intl package](https://pub.dev/packages/intl) is `(language)_(COUNTRY)` only.
However, Flutter's [Locale](https://api.flutter.dev/flutter/dart-ui/Locale-class.html) format is
`(language)_(Script)_(COUNTRY)` which triggered fallback to `(language)` only. Therefore, this package
aims to handle correct language system by define country code with corresponded scripting.
## Get started
### Before start
The future release in major version number of this package will depend on the latest major version of Dart and Flutter SDK.
It may rewrite new syntax to satisify use case which no longer compatable for older release one.
**To avoid this issue, you may required to run `flutter upgrade` before install it.**
### Install
Install `intl` and this package by using command:
```bash
flutter pub add intl intl_script_recognizer
```
or modify `dependencies` in `pubspec.yaml` directly:
```yaml
# pubspec.yaml
depencencies:
intl: any
intl_script_recognizer: ^2.2.0
```
Then, import dependencies into your project:
```dart
import 'package:intl/intl.dart';
import 'package:intl_script_recognizer/base.dart';
```
If `DateFormat` is required, it is highly recommended to import date format extension package:
```dart
import 'package:intl_script_recognizer/date_format.dart';
```
By default, `IntlScriptRecognizer` will recognized "Traditional Chinese" (`zh_Hant`) to "Chinese (Taiwan)" (`zh_TW`) once the
instance has been created. If you preferred to uses another country or region's varient (in this case, Hong Kong), it is possible
to override assigned record by activating `replaceExisted` like [example](https://github.com/rk0cc/intl_script_recognizer/blob/main/example/main.dart).
## License
BSD-3