stacked_localisation_generator 0.1.0+1 copy "stacked_localisation_generator: ^0.1.0+1" to clipboard
stacked_localisation_generator: ^0.1.0+1 copied to clipboard

discontinued

a package that generates string keys for use with the the localisation service in a type safe manner

Stacked Localisation Generator #

A code generator that generates all the keys in a language file to be used with the stacked_localisation package.

Setup #

This package should be added as a dev dependency in the project you're using.

dev_dependencies:
  ...
  stacked_localisation_generator:

Then create a new folder in root called assets with another folder inside it called lang. This folder will contain the language json files. Here's an example of a file called en.json

{
  "HomeView": {
    "title": "This is my Home",
    "subtitle": "I live in this Home"
  }
}

When you run flutter pub run build_runner build --delete-conflicting-outputs the package will generate a new file called localisation_string_keys.dart that can be found at the root of the lib folder that contains type save keys for the language string definition above. The json above will produce the following keys.

/// This code is generated. DO NOT edit by hand

class HomeViewStrings {
  static String title = 'HomeView.title';
  static String subtitle = 'HomeView.subtitle';
}

This can be accessed statically throughout the application where the keys are required. To see a full example of using stacked_localisaion you can check out the walkthrough here.

2
likes
20
pub points
0%
popularity

Publisher

verified publisherfilledstacks.com

a package that generates string keys for use with the the localisation service in a type safe manner

Homepage
Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

analyzer, build, glob, mustache, path, source_gen

More

Packages that depend on stacked_localisation_generator