xyz_config 0.31.0 copy "xyz_config: ^0.31.0" to clipboard
xyz_config: ^0.31.0 copied to clipboard

discontinuedreplaced by: df_config

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

πŸ‡½πŸ‡ΎπŸ‡Ώ 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.

3
likes
110
points
218
downloads

Publisher

unverified uploader

Weekly Downloads

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

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

df_collection, df_type, equatable, meta, path, yaml

More

Packages that depend on xyz_config