chain-studio/lib/widgets/chain_en_badge.dart
flemming-it 891acd2ba2
Some checks failed
Security / Security check (push) Failing after 2s
refactor: rename internal Fai* design system + fai_ helpers to chain
The Studio design system, widgets and helpers carried a Fai* / fai_
prefix (FaiSpace, FaiColors, FaiTheme, FaiLog, 17 fai_*.dart files, the
faiBinary* l10n keys). Studio is the Ch∆In product, so rename them to
Chain* / chain_ — carefully preserving English fail/failure/failed.
Also fix stale references: the 'fai' binary in l10n strings -> 'chain',
FAI_* env vars (FAI_BIN/DATA_DIR/MODULES_DIR/TODAY/BOOTSTRAP_TOKEN) ->
CHAIN_*, fai_platform -> fai_chain, fai_hub -> chain_hub. Vendor
security-hook tooling (FAI_BANNED_TERMS_FILE) + the .fai bundle ext left.
flutter analyze + test: clean (20 passed).

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
2026-06-16 17:53:17 +02:00

59 lines
2.1 KiB
Dart

// ChainEnBadge — small "[EN]" pill shown next to text that came
// from outside Studio's localization pipeline (MCP server tool
// names, n8n endpoint descriptions, native LLM responses).
//
// The honest move: when the active locale isn't English and we
// show a piece of text that we know is English, mark it so the
// operator doesn't blame Studio for a half-translated page.
// `studio.translate` plugin will eventually rewrite these in
// place — until then, the badge is the right amount of
// transparency.
import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart';
import '../theme/tokens.dart';
class ChainEnBadge extends StatelessWidget {
/// When true, the badge renders. When false (e.g. the active
/// locale already is English), it returns
/// `SizedBox.shrink()` so callers can drop it inline without
/// guarding visibility themselves.
final bool visible;
const ChainEnBadge({super.key, required this.visible});
/// Convenience constructor: derives `visible` from the active
/// Localizations locale. Use this from inside a Build method
/// where you already have a BuildContext.
factory ChainEnBadge.forContext(BuildContext context) {
final lang = Localizations.localeOf(context).languageCode;
return ChainEnBadge(visible: lang != 'en');
}
@override
Widget build(BuildContext context) {
if (!visible) return const SizedBox.shrink();
final theme = Theme.of(context);
final l = AppLocalizations.of(context)!;
return Tooltip(
message: l.mcpServerEnLanguageBadge,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(ChainRadius.sm),
border: Border.all(color: theme.colorScheme.outlineVariant),
),
child: Text(
'EN',
style: theme.textTheme.labelSmall?.copyWith(
fontSize: 9,
letterSpacing: 0.4,
color: theme.colorScheme.onSurfaceVariant,
),
),
),
);
}
}