easy_localization 2.1.0-dev.0 copy "easy_localization: ^2.1.0-dev.0" to clipboard
easy_localization: ^2.1.0-dev.0 copied to clipboard

outdated

Easy and Fast internationalizing and localization your Flutter Apps, this package simplify the internationalizing process using Json file.

example/lib/main.dart

import 'dart:developer';
import 'dart:ui';

import 'package:example/custom_asset_loader.dart';
import 'package:example/lang_view.dart';
import 'package:example/my_flutter_app_icons.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:easy_localization/easy_localization.dart';

void main() {
  runApp(EasyLocalization(
    child: MyApp(),
    supportedLocales: [
      Locale('en', 'US'),
      Locale('ar', 'DZ'),
      Locale('de', 'DE'),
      Locale('ru', 'RU')
    ],
    path: 'resources/langs/langs.csv',//'resources/langs',
    // fallbackLocale: Locale('en', 'US'),
    // saveLocale: false,
    useOnlyLangCode: true,
    // optional assetLoader default used is RootBundleAssetLoader which uses flutter's assetloader
    assetLoader: CsvAssetLoader(),
    // assetLoader: RootBundleAssetLoader()
    // assetLoader: NetworkAssetLoader()
    // assetLoader: TestsAssetLoader()
    // assetLoader: FileAssetLoader()
    // assetLoader: StringAssetLoader()
    // preloaderColor: Colors.red,
  ));
}
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    log(EasyLocalization.of(context).locale.toString(),
        name: '${this} # locale');
    log('title'.tr().toString(), name: '${this} # locale');
    return MaterialApp(
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        EasyLocalization.of(context).delegate,
      ],
      supportedLocales: EasyLocalization.of(context).supportedLocales,
      locale: EasyLocalization.of(context).locale,
      //  locale:  EasyLocalization.of(context).locale= Locale(Intl.systemLocale.toString().split("_")[0]),

      home: Scaffold(
        appBar: AppBar(
          //right here
          title: Text('title'.tr()),
        ),
        body: LanguageView(),
      ),
    );
  }
}
2936
likes
0
pub points
100%
popularity

Publisher

unverified uploader

Easy and Fast internationalizing and localization your Flutter Apps, this package simplify the internationalizing process using Json file.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, flutter_localizations, intl, shared_preferences

More

Packages that depend on easy_localization