flutter_csv_localization 0.3.1

Flutter localizations generator from CSV files. #

Generates a localizations delegate from a CSV file.

Usage #

Install globally the tool :

$ pub global activate flutter_csv_localization

CSV #

Then run the generator :

$ pub global run flutter_csv_localization:generate -o example.g.dart example.csv

Google Sheet #

Make sure that your sheet is shared :

share

Extract from the link the DOCID and SHEETID values : https://docs.google.com/spreadsheets/d/<DOCID>/edit#gid=<SHEETID>) :

Run the command :

$ pub global run flutter_csv_localization:generate -g -o example.g.dart <DOCID>/<SHEETID>

Example #

.csv -> .dart

CSV format #

The csv file should have :

  • Row
    • Column 0 : "Key"
    • then each supported language code ("en", "fr", ...)
  • Following rows for labels
    • Column 0 : the label key (can be a hierarchy, separated by dots)
    • then each translation based on language code of the column

example

Key,fr,en
dates.weekday.monday,lundi,monday
dates.weekday.tuesday,mardi,tuesday
dates.weekday.wednesday,mercredi,wednesday
dates.weekday.thursday,jeudi,thursday
dates.weekday.friday,vendredi,friday
dates.weekday.saturday,samedi,saturday
dates.weekday.sunday,dimanche,sunday

Roadmap / Ideas #

  • [ ] Multiple values per label (plural, gender, ...)
  • [ ] Native labels (plist, xml, ...)

Why ? #

I find the Flutter internationalization tools not really easy to use, and I wanted a simple tool for sharing translations.

1.0.0 #

  • Initial version, created by Stagehand

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_csv_localization: ^0.3.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:flutter_csv_localization/flutter_csv_localization.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
87
Overall:
Weighted score of the above. [more]
47
Learn more about scoring.

We analyzed this package on Jul 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19

Platforms

Detected platforms: Flutter, other

Primary library: package:flutter_csv_localization/flutter_csv_localization.dart with components: io.

Health issues and suggestions

Document public APIs. (-1 points)

30 out of 30 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix bin/generate.dart. (-0.50 points)

Analysis of bin/generate.dart reported 1 hint:

line 30 col 5: DO use curly braces for all flow control structures.

Fix lib/src/localizations.dart. (-0.50 points)

Analysis of lib/src/localizations.dart reported 1 hint:

line 39 col 9: Use isNotEmpty instead of length

Fix lib/src/parser.dart. (-0.50 points)

Analysis of lib/src/parser.dart reported 1 hint:

line 35 col 13: Use isNotEmpty instead of length

Format lib/src/builder.dart.

Run dartfmt to format lib/src/builder.dart.

Maintenance suggestions

The package description is too short. (-13 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 flutter_csv_localization.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.0.0 <3.0.0
args ^1.5.1 1.5.2
code_builder ^3.2.0 3.2.0
csv ^4.0.3 4.0.3
dart_style ^1.2.7 1.2.9
http ^0.12.0 0.12.0+2
meta ^1.1.7 1.1.7
recase ^2.0.1 2.0.1
Transitive dependencies
analyzer 0.37.0
async 2.2.0
built_collection 4.2.2
built_value 6.7.0
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
csslib 0.16.1
fixnum 0.10.9
front_end 0.1.20
glob 1.1.7
html 0.14.0+2
http_parser 3.1.3
kernel 0.3.20
matcher 0.12.5
package_config 1.0.5
path 1.6.2
pedantic 1.8.0+1
pub_semver 1.4.2
quiver 2.0.3
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+12
yaml 2.1.16

Admin