LocalePlugin class

Plugin for managing internationalization across features

This plugin provides centralized locale management and allows features to register their locale change handlers.

Usage in features:

final feature = FeatureDescriptor(
  init: () async {
    final localePlugin = vyuh.getPlugin<LocalePlugin>();
    if (localePlugin != null) {
      localePlugin.registerTranslations(
        TranslationRegistration(
          name: 'my_feature',
          onLocaleChange: (locale) async {
            final appLocale = _convertToAppLocale(locale);
            await FeatureLocaleSettings.setLocale(appLocale);
          },
        ),
      );
    }
  },
);
Inheritance

Constructors

LocalePlugin({required List<LocaleConfiguration> locales, LocaleConfiguration? defaultLocale})

Properties

currentLocale ↔ Observable<Locale>
Raw observable for the current locale (no codegen)
latefinal
currentLocaleCode → String
Get the current locale code
no setter
defaultLocale → LocaleConfiguration
Get the default locale configuration
no setter
hashCode → int
The hash code for this object.
no setterinherited
isLoadingLocale → Observable<bool>
Raw observable to track locale loading state (no codegen)
final
locales → List<LocaleConfiguration>
List of supported locale configurations
final
name → String
finalinherited
registrationCount → int
Number of registered translations
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
supportedLocales → List<Locale>
Available locales in the application
no setter
title → String
finalinherited

Methods

dispose() → Future<void>
override
getLocaleIcon(String localeCode) → String
Get the icon/emoji for a locale code
getLocaleName(String localeCode) → String
Get the native name for a locale code
init() → Future<void>
override
isLocaleActive(Locale locale) → bool
Check if a specific locale is currently active
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerTranslations(TranslationRegistration registration) → void
Register a feature's translation configuration
setLocale(Locale locale) → Future<bool>
Set the application locale
toString() → String
A string representation of this object.
inherited
useDeviceLocale() → Future<void>
Use the device's locale if supported, otherwise default to configured default

Operators

operator ==(Object other) → bool
The equality operator.
inherited