Skip to content
This repository was archived by the owner on Oct 12, 2024. It is now read-only.
/ xyz_config Public archive

This package allows you to add configurations and language support to your apps.

License

Notifications You must be signed in to change notification settings

robmllze/xyz_config

Repository files navigation

🇽🇾🇿 Config

pub package

This package allows you to add configurations and language support to your apps.

Quickstart

  1. Create translation files at YOUR_PROJECT/assets/translations/.
# en_us.yaml
messages:
  welcome_message: Welcome to this app!
languages:
  en_us: English
  af_za: Afrikaans
# af_za.yaml
messages:
  welcome_message: Welkom by hierdie app!
languages:
  en_us: Engels
  af_za: Afrikaans
  1. Create the translation file reader.
  final translationFileReader = TranslationFileReader(
    // The path to the translations directory, e.g. rootBundle looks at 'assets/translations'.
    translationsDirPath: ['translations'],
    // The translation file type, e.g. YAML, JSON, JSONC, CSV, etc.
    fileType: ConfigFileType.YAML,
    // The translation file reader, e.g. rootBundle, http, file, etc.
    fileReader: (filePath) => rootBundle.loadString(filePath),
  );
  1. Change the language and use the translations.
  Button(
    onTap: () async {
      // Translate app to English (en_us.yaml).
      await translationFileReader.read('en_us');
      // Refresh the UI. You will have to refresh the app at the top level so that all widgets can update.
      setState(() {});
    },
    child: Text('English||languages.en_us'.tr()),
  )

  Button(
    onTap: () async {
      // Translate app to Afrikaans (af_za.yaml).
      await translationFileReader.read('af_za');
      setState(() {});
    },
    child: Text('Afrikaans||languages.af_za'.tr()),
  )

  Text('Hmmm... welcome!||messages.welcome_message'.tr()); // Defaults to "Hmmm... welcome!" if the translation at "messages.welcome_message" isn't found.

Tip: File names are case sensitive on most Linux based systems like Firebase Hosting. Make sure to use the correct case for your file paths. As a rule of thumb, always use lowercase file paths.

Documentation

🔜 Documentation and video tutorials are coming soon. Feel free to contact me for more information.

Installation

Use this package as a dependency by adding it to your pubspec.yaml file (see here), or copy the needed source code directly into your project.

Contributing and Discussions

This is an open-source project, and contributions are welcome from everyone, regardless of experience level. Contributing to projects is a great way to learn, share knowledge, and showcase your skills to the community. Join the discussions to ask questions, report bugs, suggest features, share ideas, or find out how you can contribute.

Join GitHub Discussions:

💬 https://github.com/robmllze/xyz_config/discussions

Join Reddit Discussions:

💬 https://www.reddit.com/r/xyz_config/

Chief Maintainer:

📧 Email Robert Mollentze at robmllze@gmail.com

License

This project is released under the MIT License. See LICENSE for more information.

About

This package allows you to add configurations and language support to your apps.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages