zooper_flutter_localization 1.0.0 copy "zooper_flutter_localization: ^1.0.0" to clipboard
zooper_flutter_localization: ^1.0.0 copied to clipboard

outdated

A simple localization library

zooper_flutter_localization #

A simple localization library. This lib is aimed to work with get_it or injectable, but it should works for any other framework.

Example #

This example aims to use this package with injectable, but you should be able to implement it with any other framework, or even without

Importing #

Add this line to your pubspec.yaml:

zooper_flutter_localization: <latest>

and inside your dart class:

import 'package:zooper_flutter_localization/zooper_flutter_localization.dart';

Registering with injectable #

If you want to register a localizer for a specific View (better use ViewModels if you use the MVVM Pattern), you can define a Module with injectable:

import 'package:injectable/injectable.dart';
import 'package:zooper_flutter_localization/zooper_flutter_localization.dart';

@module
abstract class LocalizationModule {
  LocalizationService get localizationService;

  @preResolve
  Future<ZooperLocalizer<TestView>> testViewModelLocalizations(
          LocalizationService localizationService) =>
      localizationService.registerAsync<TestView>(
          'assets/localizations/localizations.csv');
}

This registers a ZooperLocalizer with the TestView and loads the translations from the defined file. Then you can inject it easily:

class TestView {
  late final ZooperLocalizer<TestViewModel> _localizer;

  TestView(this._localizer);
}

Accessing a translation #

This can be done in multiple ways. Easist is this:

_localizer['Hello'];

but you can do also:

_localizer.getLocalization('Hello');

or with a specific locale:

_localizer.getLocalizationByLocale('Hello', Locale('de', 'DE'))
1
likes
0
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

A simple localization library

Homepage

License

unknown (license)

Dependencies

collection, csv, flutter, path

More

Packages that depend on zooper_flutter_localization