dissolve app/ into repo root (D-056)
Single Flutter package at the repo root. All code, tests, assets, and platform directories moved from app/ to root. Package renamed from clide_app to clide — all imports rewritten. Merged pubspec combines core (ffi) and app (flutter, yaml, xterm) dependencies. Makefile simplified: no APP_PRESENT conditionals, no cd, no daemon lifecycle. 317 tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
/// Resolves the ordered list of locales to try when looking up a key.
|
||||
///
|
||||
/// Order, starting from the current locale:
|
||||
/// 1. exact (language + country) — e.g. nl_NL
|
||||
/// 2. language-only — e.g. nl
|
||||
/// 3. default language + country — e.g. en_US
|
||||
/// 4. default language-only — e.g. en
|
||||
///
|
||||
/// Duplicates are removed while preserving order. `null` country code is
|
||||
/// canonicalized by omitting it (not empty string) so equality works.
|
||||
@immutable
|
||||
class FallbackChain {
|
||||
const FallbackChain({
|
||||
required this.current,
|
||||
required this.defaultLocale,
|
||||
});
|
||||
|
||||
final Locale current;
|
||||
final Locale defaultLocale;
|
||||
|
||||
List<Locale> resolve() {
|
||||
final out = <Locale>[];
|
||||
for (final l in [
|
||||
current,
|
||||
Locale(current.languageCode),
|
||||
defaultLocale,
|
||||
Locale(defaultLocale.languageCode),
|
||||
]) {
|
||||
final canon = _canon(l);
|
||||
if (!out.any((e) => _canon(e) == canon)) {
|
||||
out.add(l);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static String _canon(Locale l) {
|
||||
final country = l.countryCode;
|
||||
if (country == null || country.isEmpty) return l.languageCode;
|
||||
return '${l.languageCode}_$country';
|
||||
}
|
||||
|
||||
/// Canonical filename suffix for a locale, matching fframe: `en_us`
|
||||
/// (lowercase, country only when present).
|
||||
static String filenameSuffix(Locale l) {
|
||||
final lang = l.languageCode.toLowerCase();
|
||||
final country = l.countryCode?.toLowerCase();
|
||||
if (country == null || country.isEmpty) return lang;
|
||||
return '${lang}_$country';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user