tradutor 0.9.2
tradutor: ^0.9.2 copied to clipboard
A Flutter package that simplify the internationalizing process using JSON and YAML files.
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'i18n.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
const i18n = I18n.delegate;
return MaterialApp(
title: 'Tradutor',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const HomePage(),
localizationsDelegates: [
i18n,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: i18n.supportedLocales,
localeResolutionCallback: i18n.resolution(
fallback: const Locale('en', 'US'),
),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({
Key key,
}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
var _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
final i18n = I18n.of(context);
return Scaffold(
appBar: AppBar(
title: Text(i18n.simpleMessage),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(i18n.pluralMesssage(_counter)),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
child: const Icon(Icons.add),
),
);
}
}