chain-studio/lib/l10n/app_localizations.dart
flemming-it ee83eb851a feat(studio): app-wide i18n via flutter_localizations (v0.24.0)
Replaces the Store-only DE/EN toggle with an app-wide one
parked in the sidebar footer next to the theme button.
Pressing it flips every translated string at once: nav
labels, page titles, common buttons, the bilingual
store-index content.

Implementation:
- Adds `flutter_localizations` + `intl` to pubspec, plus
  `flutter.generate: true` so `flutter gen-l10n` runs in the
  build pipeline.
- ARB sources at `lib/l10n/app_en.arb` and `app_de.arb`. The
  EN file is the template; DE carries the German strings.
  Initial coverage: navigation, common buttons, page titles,
  channels / store / audit / modules / approvals headers,
  hub-unreachable copy, MCP + n8n panel headers + hints.
  Rest of the UI strings are still English-literal — those
  fall in incrementally as we touch each surface.
- Generated `AppLocalizations` lives at
  `lib/l10n/app_localizations*.dart` (regenerated via
  `flutter gen-l10n` on every ARB edit).
- `StudioAppState` gains `localeNotifier` alongside
  `modeNotifier`; persisted via SharedPreferences key
  `locale.code`.
- Sidebar `_LanguageToggle` reads/writes through the
  notifier. The Store's per-page locale state is gone:
  `_locale` now reads `Localizations.localeOf(context)
  .languageCode`, so the bilingual store-index content
  follows the global setting without a second toggle.
- `_NavPage.label` becomes `_NavPage.id` + `labelOf(context)`;
  Cmd+K palette and Sidebar both read the localized label.

Out of scope this iteration: localizing the remaining
~80% of UI strings (Settings dialog labels, Store search
hint, error messages). Those land incrementally — the i18n
infrastructure now means each is a one-line ARB edit + one
call-site swap.

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
2026-05-08 01:19:32 +02:00

572 lines
16 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:intl/intl.dart' as intl;
import 'app_localizations_de.dart';
import 'app_localizations_en.dart';
// ignore_for_file: type=lint
/// Callers can lookup localized strings with an instance of AppLocalizations
/// returned by `AppLocalizations.of(context)`.
///
/// Applications need to include `AppLocalizations.delegate()` in their app's
/// `localizationDelegates` list, and the locales they support in the app's
/// `supportedLocales` list. For example:
///
/// ```dart
/// import 'l10n/app_localizations.dart';
///
/// return MaterialApp(
/// localizationsDelegates: AppLocalizations.localizationsDelegates,
/// supportedLocales: AppLocalizations.supportedLocales,
/// home: MyApplicationHome(),
/// );
/// ```
///
/// ## Update pubspec.yaml
///
/// Please make sure to update your pubspec.yaml to include the following
/// packages:
///
/// ```yaml
/// dependencies:
/// # Internationalization support.
/// flutter_localizations:
/// sdk: flutter
/// intl: any # Use the pinned version from flutter_localizations
///
/// # Rest of dependencies
/// ```
///
/// ## iOS Applications
///
/// iOS applications define key application metadata, including supported
/// locales, in an Info.plist file that is built into the application bundle.
/// To configure the locales supported by your app, youll need to edit this
/// file.
///
/// First, open your projects ios/Runner.xcworkspace Xcode workspace file.
/// Then, in the Project Navigator, open the Info.plist file under the Runner
/// projects Runner folder.
///
/// Next, select the Information Property List item, select Add Item from the
/// Editor menu, then select Localizations from the pop-up menu.
///
/// Select and expand the newly-created Localizations item then, for each
/// locale your application supports, add a new item and select the locale
/// you wish to add from the pop-up menu in the Value field. This list should
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
/// property.
abstract class AppLocalizations {
AppLocalizations(String locale)
: localeName = intl.Intl.canonicalizedLocale(locale.toString());
final String localeName;
static AppLocalizations? of(BuildContext context) {
return Localizations.of<AppLocalizations>(context, AppLocalizations);
}
static const LocalizationsDelegate<AppLocalizations> delegate =
_AppLocalizationsDelegate();
/// A list of this localizations delegate along with the default localizations
/// delegates.
///
/// Returns a list of localizations delegates containing this delegate along with
/// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
/// and GlobalWidgetsLocalizations.delegate.
///
/// Additional delegates can be added by appending to this list in
/// MaterialApp. This list does not have to be used at all if a custom list
/// of delegates is preferred or required.
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
<LocalizationsDelegate<dynamic>>[
delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
];
/// A list of this localizations delegate's supported locales.
static const List<Locale> supportedLocales = <Locale>[
Locale('de'),
Locale('en'),
];
/// App-bar title in the OS task switcher.
///
/// In en, this message translates to:
/// **'F∆I Studio'**
String get appTitle;
/// No description provided for @navDoctor.
///
/// In en, this message translates to:
/// **'Doctor'**
String get navDoctor;
/// No description provided for @navModules.
///
/// In en, this message translates to:
/// **'Modules'**
String get navModules;
/// No description provided for @navStore.
///
/// In en, this message translates to:
/// **'Store'**
String get navStore;
/// No description provided for @navFlows.
///
/// In en, this message translates to:
/// **'Flows'**
String get navFlows;
/// No description provided for @navAudit.
///
/// In en, this message translates to:
/// **'Audit'**
String get navAudit;
/// No description provided for @navApprovals.
///
/// In en, this message translates to:
/// **'Approvals'**
String get navApprovals;
/// No description provided for @connectionConnected.
///
/// In en, this message translates to:
/// **'connected'**
String get connectionConnected;
/// No description provided for @connectionUnreachable.
///
/// In en, this message translates to:
/// **'unreachable'**
String get connectionUnreachable;
/// No description provided for @connectionConnecting.
///
/// In en, this message translates to:
/// **'connecting…'**
String get connectionConnecting;
/// No description provided for @connectionStartHub.
///
/// In en, this message translates to:
/// **'Start hub'**
String get connectionStartHub;
/// No description provided for @buttonCancel.
///
/// In en, this message translates to:
/// **'Cancel'**
String get buttonCancel;
/// No description provided for @buttonSave.
///
/// In en, this message translates to:
/// **'Save'**
String get buttonSave;
/// No description provided for @buttonClose.
///
/// In en, this message translates to:
/// **'Close'**
String get buttonClose;
/// No description provided for @buttonRetry.
///
/// In en, this message translates to:
/// **'Retry'**
String get buttonRetry;
/// No description provided for @buttonRefresh.
///
/// In en, this message translates to:
/// **'Refresh'**
String get buttonRefresh;
/// No description provided for @buttonInstall.
///
/// In en, this message translates to:
/// **'Install'**
String get buttonInstall;
/// No description provided for @buttonUninstall.
///
/// In en, this message translates to:
/// **'Uninstall'**
String get buttonUninstall;
/// No description provided for @buttonDetails.
///
/// In en, this message translates to:
/// **'Details'**
String get buttonDetails;
/// No description provided for @buttonAdd.
///
/// In en, this message translates to:
/// **'Add'**
String get buttonAdd;
/// No description provided for @buttonRemove.
///
/// In en, this message translates to:
/// **'Remove'**
String get buttonRemove;
/// No description provided for @buttonOpen.
///
/// In en, this message translates to:
/// **'Open'**
String get buttonOpen;
/// No description provided for @buttonExplain.
///
/// In en, this message translates to:
/// **'Explain'**
String get buttonExplain;
/// No description provided for @buttonReadDocs.
///
/// In en, this message translates to:
/// **'Read docs'**
String get buttonReadDocs;
/// No description provided for @settingsTitle.
///
/// In en, this message translates to:
/// **'Hub endpoint'**
String get settingsTitle;
/// No description provided for @settingsHost.
///
/// In en, this message translates to:
/// **'Host'**
String get settingsHost;
/// No description provided for @settingsPort.
///
/// In en, this message translates to:
/// **'Port'**
String get settingsPort;
/// No description provided for @settingsTls.
///
/// In en, this message translates to:
/// **'TLS'**
String get settingsTls;
/// No description provided for @settingsSaveAndConnect.
///
/// In en, this message translates to:
/// **'Save & connect'**
String get settingsSaveAndConnect;
/// No description provided for @settingsLanguage.
///
/// In en, this message translates to:
/// **'Language'**
String get settingsLanguage;
/// No description provided for @settingsLanguageHint.
///
/// In en, this message translates to:
/// **'App language. Affects every page; bilingual store entries also flip via this toggle.'**
String get settingsLanguageHint;
/// No description provided for @channelsHeader.
///
/// In en, this message translates to:
/// **'CHANNELS'**
String get channelsHeader;
/// No description provided for @channelsActive.
///
/// In en, this message translates to:
/// **'active'**
String get channelsActive;
/// No description provided for @channelsRunning.
///
/// In en, this message translates to:
/// **'running'**
String get channelsRunning;
/// No description provided for @channelsStopped.
///
/// In en, this message translates to:
/// **'stopped'**
String get channelsStopped;
/// No description provided for @channelsConnect.
///
/// In en, this message translates to:
/// **'Connect Studio to this channel'**
String get channelsConnect;
/// No description provided for @channelsSwitch.
///
/// In en, this message translates to:
/// **'Make this the active channel'**
String get channelsSwitch;
/// No description provided for @channelsEnableAutostart.
///
/// In en, this message translates to:
/// **'Enable autostart at login'**
String get channelsEnableAutostart;
/// No description provided for @channelsDisableAutostart.
///
/// In en, this message translates to:
/// **'Disable autostart'**
String get channelsDisableAutostart;
/// No description provided for @storeSearchHint.
///
/// In en, this message translates to:
/// **'Search modules — name, tagline, tag, capability…'**
String get storeSearchHint;
/// No description provided for @storeFeatured.
///
/// In en, this message translates to:
/// **'FEATURED'**
String get storeFeatured;
/// No description provided for @storeFeaturedHint.
///
/// In en, this message translates to:
/// **'curated picks · click for details'**
String get storeFeaturedHint;
/// No description provided for @storeNoMatches.
///
/// In en, this message translates to:
/// **'No matches'**
String get storeNoMatches;
/// No description provided for @storeNoMatchesHint.
///
/// In en, this message translates to:
/// **'Adjust the filters or clear the search to see all entries.'**
String get storeNoMatchesHint;
/// No description provided for @storeClearFilters.
///
/// In en, this message translates to:
/// **'Clear filters'**
String get storeClearFilters;
/// No description provided for @storeStatusAll.
///
/// In en, this message translates to:
/// **'All'**
String get storeStatusAll;
/// No description provided for @storeStatusPublished.
///
/// In en, this message translates to:
/// **'Published'**
String get storeStatusPublished;
/// No description provided for @storeStatusAlpha.
///
/// In en, this message translates to:
/// **'Alpha'**
String get storeStatusAlpha;
/// No description provided for @storeStatusPlanned.
///
/// In en, this message translates to:
/// **'Planned'**
String get storeStatusPlanned;
/// No description provided for @storeInstalledOnly.
///
/// In en, this message translates to:
/// **'Installed'**
String get storeInstalledOnly;
/// No description provided for @storeNResults.
///
/// In en, this message translates to:
/// **'{n} result{n, plural, =1{} other{s}}'**
String storeNResults(int n);
/// No description provided for @auditTitle.
///
/// In en, this message translates to:
/// **'Audit'**
String get auditTitle;
/// No description provided for @auditNoEvents.
///
/// In en, this message translates to:
/// **'No events yet'**
String get auditNoEvents;
/// No description provided for @auditNoEventsHint.
///
/// In en, this message translates to:
/// **'Run a flow to populate the audit stream.\nEvents appear here within seconds.'**
String get auditNoEventsHint;
/// No description provided for @modulesTitle.
///
/// In en, this message translates to:
/// **'Modules'**
String get modulesTitle;
/// No description provided for @modulesNoneTitle.
///
/// In en, this message translates to:
/// **'No modules yet'**
String get modulesNoneTitle;
/// No description provided for @modulesRecentActivity.
///
/// In en, this message translates to:
/// **'RECENT ACTIVITY'**
String get modulesRecentActivity;
/// No description provided for @approvalsTitle.
///
/// In en, this message translates to:
/// **'Approvals'**
String get approvalsTitle;
/// No description provided for @approvalsTabPending.
///
/// In en, this message translates to:
/// **'Pending'**
String get approvalsTabPending;
/// No description provided for @approvalsTabHistory.
///
/// In en, this message translates to:
/// **'History'**
String get approvalsTabHistory;
/// No description provided for @approvalsInboxZero.
///
/// In en, this message translates to:
/// **'Inbox zero'**
String get approvalsInboxZero;
/// No description provided for @approvalsInboxHint.
///
/// In en, this message translates to:
/// **'All caught up. New `system.approval@^0` steps land here automatically.'**
String get approvalsInboxHint;
/// No description provided for @doctorTitle.
///
/// In en, this message translates to:
/// **'Doctor'**
String get doctorTitle;
/// No description provided for @mcpHeader.
///
/// In en, this message translates to:
/// **'MCP CLIENTS'**
String get mcpHeader;
/// No description provided for @mcpHint.
///
/// In en, this message translates to:
/// **'External MCP servers federate their tools as `mcp.<server>.<tool>` capabilities. Configure once, see them in the Store.'**
String get mcpHint;
/// No description provided for @mcpEmpty.
///
/// In en, this message translates to:
/// **'No MCP servers configured. Click + to add one.'**
String get mcpEmpty;
/// No description provided for @n8nHeader.
///
/// In en, this message translates to:
/// **'N8N ENDPOINTS'**
String get n8nHeader;
/// No description provided for @n8nHint.
///
/// In en, this message translates to:
/// **'Active n8n workflows surface as `n8n.<endpoint>.<slug>` capabilities. Configure once, see them in the Store.'**
String get n8nHint;
/// No description provided for @n8nEmpty.
///
/// In en, this message translates to:
/// **'No n8n endpoints configured. Click + to add one.'**
String get n8nEmpty;
/// No description provided for @hubUnreachable.
///
/// In en, this message translates to:
/// **'Hub unreachable'**
String get hubUnreachable;
/// No description provided for @hubUnreachableHint.
///
/// In en, this message translates to:
/// **'Start the hub with `fai serve`.'**
String get hubUnreachableHint;
/// No description provided for @languageEnglish.
///
/// In en, this message translates to:
/// **'English'**
String get languageEnglish;
/// No description provided for @languageGerman.
///
/// In en, this message translates to:
/// **'Deutsch'**
String get languageGerman;
}
class _AppLocalizationsDelegate
extends LocalizationsDelegate<AppLocalizations> {
const _AppLocalizationsDelegate();
@override
Future<AppLocalizations> load(Locale locale) {
return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
}
@override
bool isSupported(Locale locale) =>
<String>['de', 'en'].contains(locale.languageCode);
@override
bool shouldReload(_AppLocalizationsDelegate old) => false;
}
AppLocalizations lookupAppLocalizations(Locale locale) {
// Lookup logic when only language code is specified.
switch (locale.languageCode) {
case 'de':
return AppLocalizationsDe();
case 'en':
return AppLocalizationsEn();
}
throw FlutterError(
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.',
);
}