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

LanguageHandling 1.0.0 is a powerful Flutter package designed to simplify language localization within your Flutter applications. With LanguageHandling, developers can effortlessly integrate multi-lan [...]

Language Handling #

Language Handling is a Flutter package for handling language localization and internationalization in your Flutter applications.

Getting Started #

Prerequisites #

Before using this package, ensure you have Flutter installed.

Installation #

Add the following dependency to your pubspec.yaml file:

dependencies:
  your_package_name: ^1.0.0
.

Android Configuration #

In your android/app/build.gradle, make sure you have the following configurations:

android {
    ...

    defaultConfig {
        ...
        minSdkVersion 21
        ...
    }
    ...
}

How To Use #

Prepare Language Source #

Create a Dart file which will contain all the Map data of the locale languages your app needs. You can change the file name, class name, and file path as desired. For example:

const List<MapLocale> LOCALES = [
  MapLocale("en", LocalData.EN),
  MapLocale("de", LocalData.DE),
  MapLocale("zh", LocalData.ZH)
];

mixin LocalData {
  static const String title = 'title';
  static const String body = 'body';

  static const Map<String, dynamic> EN = {
    title: 'localization',
    body: 'Welcome to this localization flutter application %a'
  };

  static const Map<String, dynamic> DE = {
    title: 'Lokalisierung',
    body: 'Willkommen bei dieser Lokalisierungs-Anwendung %a'
  };

  static const Map<String, dynamic> ZH = {
    title: '本地化',
    body: '欢迎使用这个本地化  应用程序 %a'
  };
}

Project Configuration #

Initialize the LanguageHandling object. This can be done locally or globally, depending on your preference:

final LanguageHandling localization = LanguageHandling.instance;

Initialize MapLocale List and Startup Language #

To initialize the list of MapLocale and set the startup language for your app, ensure you perform the following steps in your main.dart file or within the MaterialApp widget:

@override
void initState() {
    configureLocalization();
    super.initState();
}
@override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Language Testing',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.black),
        useMaterial3: true,
      ),
      supportedLocales: localization.supportedLocales,
      localizationsDelegates: localization.localizationsDelegates,
      home: const Homepage(),
    );
  }

  void configureLocalization() {
    localization.init(
        mapLocales: LOCALES, initLanguageCode: "en"); // Pass LOCALES here
    localization.onTranslatedLanguage = onTranslatedLanguage;
  }

  void onTranslatedLanguage(Locale? locale) {
    setState(() {});
  }


Usage #

Include short and useful examples for package users. Add longer examples to /example folder.

const like = 'sample';

Additional information #

Tell users more about the package: where to find more information, how to contribute to the package, how to file issues, what response they can expect from the package authors, and more.

3
likes
150
points
37
downloads

Publisher

unverified uploader

Weekly Downloads

LanguageHandling 1.0.0 is a powerful Flutter package designed to simplify language localization within your Flutter applications. With LanguageHandling, developers can effortlessly integrate multi-language support, providing a seamless experience for users across different linguistic backgrounds.

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_localizations, flutter_web_plugins, plugin_platform_interface, shared_preferences

More

Packages that depend on lang_apptimus