is_zh
Detect Chinese locales from a Flutter BuildContext.
Getting started
Add the package to your Flutter project:
flutter pub add is_zh
Usage
import 'package:is_zh/is_zh.dart';
// Use a context below MaterialApp, CupertinoApp, or Localizations.
final chinese = isZh(context);
final simplified = isZhSimplified(context);
final traditional = isZhTraditional(context);
All three functions read Localizations.localeOf(context) and rebuild their
calling widget when the locale changes.
isZh: true when the language code iszh.isZhSimplified: true for Chinese with scriptHans, or regionCN/SG/MYwhen no script is specified.isZhTraditional: true for Chinese with scriptHant, or regionTW/HK/MOwhen no script is specified.
An explicit script takes precedence over the region. Other explicit scripts
match neither variant. Chinese locales with no script and no recognized region
(including bare zh) match neither variant, but still match isZh.
A context without a Localizations ancestor is invalid.