flappy_translator 1.0.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

flappy_translator #

A Flutter internationalized strings generator. The idea is to automate the static Strings generation from a CSV file. This way, anybody could make a CSV file with all the translations and automatically generate corresponding Dart code.

Getting Started #

In order to use the flappy_translator package, you will have to provide your translatinos in a CSV file (formatted with comma separator).

Create a CSV and export it in "comma separated" format #

Here is our CSV example : alt text

exported file myFile.csv

appTitle,Ma super application,My awesome application,Mi gran application
subtitle,Un sous titre,A subtitle,Un subtitulò
description,Un texte avec une variable : %1$s,A text with a variable : %1$s,Un texto con una variable : %1$s
littleTest,"Voici, pour l'exemple, ""un test"" avec la variable %age$d","Here is, for the example, ""a test"" with variable %age$d","Aqui esta, por ejemplo, ""una prueba"" con la variable %age$d"

Add dependency #

    sdk: flutter

Run package #

flutter pub get
flutter pub run flappy_translator test.csv path/to/destination

Use the i18n generated file #

The package used your CV file in order to generate a file named i18n.dart in path/to/destination you provided.

Once you have this file in your project, all you have to do is :

  1. Add the I18nDelegate to your delegates
class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: [
        const I18nDelegate(),
      supportedLocales: I18nDelegate.supportedLocals,
      home: Home(),
  1. Use your generated I18n class ! :)
class Home extends StatelessWidget {
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Center(
          child: Column(
            children: <Widget>[
              Text(I18n.of(context).description(var1: 2)),
              Text(I18n.of(context).littleTest(age: 32)),

Rules and functionnalities #

Default language #

The first language's column of your CSV file will be considered as the defaultone. That means :

  • If other languages does not have translation for specific words, it will take the corrresponding one in the default language.

  • The first column must be totally filled ! It will not work otherwise.

Handling different languages for one country #

You have the possibility, since version 1.4 to write something like de_CH. It will take the Swiss's German language.

Add variables in Strings #

We added the possibility to handle variables in the Strings. This means respecting some rules :

  1. In order to be able to recognize them, you must write them this way :
  • %myVariable$d (d stands for an int type)
  • %myVariable$s (s stands for a String type)
  1. if your variable's name start with a number, the generated name will be varmyVariable Otherwise, the generated variable name would be the name you provided.
  • %1$d becomes var1
  • %age$d becomes age
  1. Variables are optional in the generated dart code

Let's take the example of the description String in the CSV we used.

The generated function signature will be :

String description({String var1,})

If the variables are not provided, the String will be given without replacing the variables placeholders.

[1.0.0] - 21/08/2019

  • Initial Release

[1.0.1] - 21/08/2019

  • Fix documentation
  • Fix template's file path

[1.0.2] - 21/08/2019

  • Fix template by handling a String instead of file

[1.0.3] - 21/08/2019

  • Fix error on CSV not well formed
  • Fix error when using Dart reserved keywords

[1.0.4] - 18/10/2019q

  • Handle possibility to have multiple languages for one country


example #

A new Flutter application.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

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

  flappy_translator: ^1.0.4

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:flappy_translator/flappy_translator.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

29 out of 29 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.

Format bin/flappy_translator.dart.

Run flutter format to format bin/flappy_translator.dart.

Format bin/i18n.dart.

Run flutter format to format bin/i18n.dart.

Format lib/flappy_translator.dart.

Run flutter format to format lib/flappy_translator.dart.

Format lib/parsing/csv_parser.dart.

Run flutter format to format lib/parsing/csv_parser.dart.

Maintenance suggestions

The package description is too short. (-14 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.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.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.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies