PWLocalizationContextExtension extension

Extension on BuildContext to easily access the localization service.

This extension provides convenient methods to access translations and locale information directly from any widget's build context, eliminating the need to manually access the localization service.

Example usage:

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Text(context.tr('welcome.message', args: {'name': 'John'}));
  }
}
on

Properties

currentLocale Locale?

Available on BuildContext, provided by the PWLocalizationContextExtension extension

Gets the current locale from the localization service.
no setter
localization PWLocalizationService

Available on BuildContext, provided by the PWLocalizationContextExtension extension

Gets the current localization service instance.
no setter

Methods

gender(String key, String gender, {Map<String, Object?>? namedArgs, String? locale}) String

Available on BuildContext, provided by the PWLocalizationContextExtension extension

Translates a key with gender forms (male, female, other).
plural(String key, num count, {Map<String, Object?>? namedArgs, String? locale}) String

Available on BuildContext, provided by the PWLocalizationContextExtension extension

Translates a key with plural forms (zero, one, many, other).
tr(String key, {Object? args, Map<String, Object?>? namedArgs, String? locale}) String

Available on BuildContext, provided by the PWLocalizationContextExtension extension

Translates a key with optional arguments using ICU message formatting.