fluent_localization 0.0.1
fluent_localization: ^0.0.1 copied to clipboard
Package that allows you to translate the app texts
fluent_localization #
Package that allows you to translate the app texts
Getting Started #
Add dependencies #
fluent_localization: ^0.0.1
Add assets folder to Flutter #
flutter:
assets:
- "assets/languages/"
Create assets files #
assets/
languages/
en.json
es.json
Build module #
Fluent.build([
LocalizationModule(),
]);
Use it #
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
// Define your supported locales
final locales = [
Locale("es"),
Locale("en"),
];
// Get localization delegates
final localizationDelegates = getApi<LocalizationApi>().getLocalizationDelegates(locales);
return MaterialApp(
title: 'Fluent Localization Demo',
localizationsDelegates: localizationDelegates,
supportedLocales: locales,
home: Scaffold(
body: Builder(
builder: (context) {
final hello = context.tl('hello');
return Center(
child: Text(hello),
);
},
),
),
);
}
}
Example #