getx_multilang_generator 0.0.1 copy "getx_multilang_generator: ^0.0.1" to clipboard
getx_multilang_generator: ^0.0.1 copied to clipboard

getx_multilang_generator is used to facilitate the automatic generation/modification of code in developing multilanguage features that utilize the getX framework.

getx_multilang_generator is used to facilitate the automatic generation/modification of code in developing multilanguage features that utilize the getX framework.

Features #

There are two features in this package, namely generating translation files from .csv and modifying the code to replace all occurrences of the 'string'.tr format with MultiLangKeys.string.tr.

Getting started #

Add Get to your pubspec.yaml file:

dev_dependencies:
	getx_multilang_generator:

Usage #

  1. Generate translation from .csv

Run command:

flutter pub run getx_multilang_generator import-csv

or

flutter pub run getx_multilang_generator import-csv folder/file.csv

The command will generate translation files in the form of multilang.dart and multilang_keys.dart in lib/core/translation. The import-csv argument is the name of the command, and the second argument is the location of the .csv file (relative to the project path). The default path for the .csv file is multilang/multilang.csv. Here is an example of multilang.csv:

key,en,id,
add,add,tambah,
warningMessage,there is unexpected error,terjadi kesalahan,

Generated multilang.dart:

import 'multilang_keys.dart';
import 'package:peppermint_sdk/peppermint_sdk.dart';

class Multilang extends Translations {
  @override
  Map<String, Map<String, String>> get keys => {
        'en': {
          MultiLangKeys.add: 'add',
          MultiLangKeys.warningMessage: 'there is unexpected error',
        },
        'id': {
          MultiLangKeys.add: 'tambah',
          MultiLangKeys.warningMessage: 'terjadi kesalahan',
        },
      };
}

Generated multilang_keys.dart:

class MultiLangKeys {
  MultiLangKeys._();
   static const String add = 'add';
   static const String warningMessage = 'warningMessage';
}
  1. Change 'string'.tr format to MultiLangKeys.string.tr

Run command:

flutter pub run getx_multilang_generator convert-tr 

or

flutter pub run getx_multilang_generator convert-tr my_project/core/translation/multilang_keys.dart

This command will replace all occurrences of the 'string'.tr format with MultiLangKeys.string.tr. The convert-tr argument is the name of the command, and the second argument is the path of the multilang_keys.dart file. Here is example of changing:

  • 'add'.tr -> MultiLangKeys.add.tr
  • 'warning'.tr -> MultiLangKeys.warning.tr

Additional information #

1
likes
130
points
25
downloads

Publisher

unverified uploader

Weekly Downloads

getx_multilang_generator is used to facilitate the automatic generation/modification of code in developing multilanguage features that utilize the getX framework.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

csv, flutter, path

More

Packages that depend on getx_multilang_generator