Giter VIP home page Giter VIP logo

firebase_remote_config_localization_loader's Introduction

firebase_remote_config_localization_loader

Features

Lets you easily set up the internationalization of your app with files that are stored in FirebaseRemoteConfig.

Getting started

  • Make sure you are using Easy Localization to internationalize your app, as this package provides an AssetLoader instance, which is defined in the Easy Localization package.
  • Add the dependency to the package to your pubspec.yaml:
dependencies:
  firebase_remote_config_localization_loader:
    git: 
        url: https://github.com/julienandco/firebase_remote_config_localization_loader
        ref: main

Usage

  • Add the following code to the main.dart of your application:
...
final supportedLocales = [const Locale('de'), const Locale('en')]; // Add your supported locales here

final localizationLoader =
    FirebaseRemoteConfigLocalizationLoader(
        configData: 
            FirebaseRemoteConfigData(
            remoteConfigInstance: FirebaseRemoteConfig.instance,
            supportedLocales: supportedLocales,
            buildRemoteConfigStringFromLocale: // Add your custom implementation here
                (locale) => 
                    'tran_${locale.languageCode}',
            ),
        fallbackAssetPath: '<your_path_to_the_local_translation_files>',
    );
await localizationLoader.init();

runApp(
    EasyLocalization(
        path: localizationLoader.path,
        assetLoader: localizationLoader.assetLoader,
        supportedLocales: supportedLocales,
        fallbackLocale: const Locale('de'),
        saveLocale: true,
        useFallbackTranslations: true,
        useOnlyLangCode: true,
        child: const App(),
    ),
);
...

๐Ÿšจ If you did not use FirebaseRemoteConfig before, you need to initialize it first. You can do this by adding the following code to the main.dart of your application, BEFORE instantiating the FirebaseRemoteConfigLocalizationLoader:

final remoteConfig = FirebaseRemoteConfig.instance;

await remoteConfig.setConfigSettings(
    RemoteConfigSettings(
      fetchTimeout: const Duration(minutes: 1),
      minimumFetchInterval: const Duration(hours: 1),
    ),
  );
await remoteConfig.fetchAndActivate();

Additional information

Feel free to contact me if you have any questions, open some pull requests, or want to contribute to this package.

firebase_remote_config_localization_loader's People

Contributors

julienandco avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.