perf: recover lost files (locale_selector.dart, terminology.py, app_zh_hant.arb)
These files were accidentally omitted during cherry-pick workflow. They were present in 639ef12 but dropped when switching to git apply workflow.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Locale-aware name selector for terminology fields.
|
||||
///
|
||||
/// Selects the appropriate field based on user locale:
|
||||
/// - zh-Hant (Traditional Chinese) → uses `_hant` suffix fields
|
||||
/// - zh (Simplified Chinese) or en (English) → uses base fields
|
||||
class LocaleNameSelector {
|
||||
const LocaleNameSelector._(this._isHant);
|
||||
|
||||
final bool _isHant;
|
||||
|
||||
/// Creates a selector from the given [locale].
|
||||
factory LocaleNameSelector.fromLocale(Locale locale) {
|
||||
final isHant = locale.scriptCode == 'Hant';
|
||||
return LocaleNameSelector._(isHant);
|
||||
}
|
||||
|
||||
/// Creates a selector from the given [context].
|
||||
factory LocaleNameSelector.of(BuildContext context) {
|
||||
final locale = Localizations.localeOf(context);
|
||||
return LocaleNameSelector.fromLocale(locale);
|
||||
}
|
||||
|
||||
/// Selects between simplified and traditional Chinese name.
|
||||
///
|
||||
/// Returns [nameHant] for zh-Hant locale, [name] otherwise.
|
||||
String name(String name, String nameHant) {
|
||||
return _isHant ? nameHant : name;
|
||||
}
|
||||
|
||||
/// Returns true if the current locale uses Traditional Chinese.
|
||||
bool get isTraditionalChinese => _isHant;
|
||||
}
|
||||
Reference in New Issue
Block a user