floca

Last updated:

0 purchases

floca Image
floca Images
Add to Cart

Description:

floca

floca #
Floca is a Flutter localization library.
Say, you have an Excel spreadsheet like this:



property
en
es
ru
hi




greeting
hi!
hola!
привет!
हाय!


farewell
bye
adiós
пока
अलविदा



Floca will let you access its content like this:
Widget build(BuildContext context) {
// getting the strings in proper language
var a = context.i18n.greeting;
var b = context.i18n.farewell;
...
}
copied to clipboard
How Floca works #
Floca is a command-line app, that takes your .csv spreadsheet and generates
a .dart file.
Then you import the generated file in the project and get all the needed
functionality, including the localized strings:
import "newly_generated.dart";
copied to clipboard
This approach gives you maximum compatibility and performance.
In addition, many potential errors are prevented at compile time.
Install #
Update pubspec.yaml:
dependencies:
flutter_localizations:
sdk: flutter

dev_dependencies:
floca: any
copied to clipboard
Get:
$ flutter pub get
copied to clipboard
Check it runs:
$ flutter pub run floca --help
copied to clipboard
Use #
1. Create the spreadsheet



property
en
es
ru
hi




greeting
hi!
hola!
привет!
हाय!


farewell
bye
adiós
пока
अलविदा



Save it as .csv file, say, string_constants.csv.
2. Generate a .dart file from it
$ flutter pub run floca string_constants.csv lib/string_constants.dart
copied to clipboard
3. Provide arguments to MaterialApp
import 'string_constants.dart'; // file we created with floca

MaterialApp(
...
supportedLocales: supportedLocales, // add this
localizationsDelegates: localizationsDelegates, // and this
...
);
copied to clipboard
4. Get localized text in your app
import 'string_constants.dart'; // file we created with floca

Widget build(BuildContext context) {
// now [context] has a new property [.i18n]
String s = context.i18n.greeting;
return Text(s);
}
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.