excel_localization 0.0.2 excel_localization: ^0.0.2 copied to clipboard
This excel localization is project that user can use to generate variable values for using localisation. and manage localization without context.
import 'package:excel_localization_example/i18n.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:excel_localization/excel_localization.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
// dont forget to add if you like to access by global context
navigatorKey: I18n.languageKey,
localizationsDelegates: const [
I18nDelegate(),
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: I18nDelegate.supportedLocals,
home: Home(),
);
}
}
class Home extends StatefulWidget {
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: Column(
children: <Widget>[
Text(I18n.translate.welcome(name: "hardy")),
// get language by passsing context
Text(I18n.of(context).plainText),
// global context also can use
Text(I18n.of(I18n.languageKey.currentState!.context)
.welcome(name: "Hello dada")),
OutlinedButton(
onPressed: () {
setState(() {
I18n.load(Locale("fr"));
});
},
child: Text("click here"))
],
),
),
),
);
}
}