easy_localization_multi 0.2.0 copy "easy_localization_multi: ^0.2.0" to clipboard
easy_localization_multi: ^0.2.0 copied to clipboard

A loader for easy_localization package that merges data from multiple other loaders.

example/lib/main.dart

import 'package:easy_localization/easy_localization.dart';
import 'package:easy_localization_multi/easy_localization_multi.dart';
import 'package:easy_localization_yaml/easy_localization_yaml.dart';
import 'package:flutter/material.dart';
import 'package:my_package/my_package.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await EasyLocalization.ensureInitialized();

  runApp(
    EasyLocalization(
      assetLoader: const MultiAssetLoader(
        [
          YamlAssetLoader(directory: 'assets/translations'),
          YamlAssetLoader(
            directory: 'assets/translations',
            package: 'my_package',
          ),
        ],
      ),
      fallbackLocale: const Locale('en'),
      path: 'unused',
      startLocale: const Locale('en'),
      supportedLocales: const [Locale('en')],
      child: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'easy_localization_yaml',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: MyHomePage(),

      // NEW
      locale: context.locale,
      localizationsDelegates: context.localizationDelegates,
      supportedLocales: context.supportedLocales,
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text('hello'.tr()),
      ),
      body: Center(
        child: MyPackageWidget(),
      ),
    );
  }
}
5
likes
150
points
999
downloads

Publisher

verified publisherainkin.com

Weekly Downloads

A loader for easy_localization package that merges data from multiple other loaders.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT-0 (license)

Dependencies

collection, easy_localization, flutter

More

Packages that depend on easy_localization_multi