localization_table 0.1.0

  • Readme
  • Changelog
  • Installing
  • new49

localization_table #

Localize you app using a localization table.

How to use #

  1. Create your table file with the .csv format.

  2. Put your supported languages in the first row, starting from the second cell.

  3. Put your string keys in the first column, starting from the second cell.

  4. Put your default language in the first cell at (0,0).

Example Table:

  1. Add the LocalizationTableDelegate to your locale delegates.
MaterialApp(
   localizationsDelegates: [
     LocalizationTableDelegate('assets/table.csv'),
     GlobalWidgetsLocalizations.delegate,
     GlobalMaterialLocalizations.delegate,
     GlobalCupertinoLocalizations.delegate,
   ],
   supportedLocales: [
     Locale('fa'),
     Locale('en'),
   ],
    home: /* ... */
)
  1. Use directly with LocalizationTable.of(context).get(key) where key is the string key of the value you want.

Using the extension method #

For ease of use there is a built in extension method that can be used in flutter projects that use dart 2.7.0 or higher.

Example

    Text('login'.getString(context))

How to use without buildContext #

void backgroundEntryPoint() async{
  final locale = Locale('en'); 
  
  final table = await LocalizationTableDelegate('assets/table.csv').load(locale);
  
  String appName = table.get('app_name');
  
  showNotification(appName);
}

[0.1.0] #

  • initial release.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  localization_table: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:localization_table/localization_table.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
97
Overall:
Weighted score of the above. [more]
49
Learn more about scoring.

We analyzed this package on Mar 26, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/localization_table.dart.

Run flutter format to format lib/localization_table.dart.

Format lib/src/extention.dart.

Run flutter format to format lib/src/extention.dart.

Maintenance suggestions

The package description is too short. (-3 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and localization_table.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
csv ^4.0.3 4.0.3
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test