feat: 添加README以及example项目,修复plugin的路径,新建basic_intl的本地依赖

This commit is contained in:
2025-09-10 15:35:07 +08:00
parent e39f42a3df
commit 4176116bb3
56 changed files with 2841 additions and 395 deletions

View File

@@ -0,0 +1,3 @@
library basic_intl;
export 'src/intl.dart';

View File

@@ -0,0 +1,3 @@
library basic_intl;
export 'src/intl.dart';

View File

@@ -0,0 +1,32 @@
import 'dart:ui';
class Intl {
static String _currentLocale = 'zh_CN';
/// 获取当前语言环境
static String getCurrentLocale() {
// 尝试从系统获取语言环境
try {
final systemLocale = PlatformDispatcher.instance.locale;
_currentLocale = '${systemLocale.languageCode}_${systemLocale.countryCode ?? 'CN'}';
} catch (e) {
_currentLocale = 'zh_CN';
}
return _currentLocale;
}
/// 设置当前语言环境
static void setCurrentLocale(String locale) {
_currentLocale = locale;
}
/// 判断是否为中文环境
static bool isChineseLocale() {
return getCurrentLocale().startsWith('zh');
}
/// 判断是否为英文环境
static bool isEnglishLocale() {
return getCurrentLocale().startsWith('en');
}
}