kurd_localization 1.0.3
kurd_localization: ^1.0.3 copied to clipboard
A Flutter localization package translations and Kurdish support.
import 'package:kurd_localization/kurd_localization.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
localizationsDelegates: [
KurdLocalizationDelegate.fromJson(
JsonAssetLoader(
path: 'assets/languages',
useSingleFile: false,
supportedLocales: ['en', 'ckb', 'krm', 'ar']),
),
...kurdishLocalizations,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: const [
Locale('ckb'),
Locale('krm'),
Locale('en'),
Locale('ar'),
],
locale: Locale(
'ckb',
),
home: MyHomePage(
title: 'Flutter Demo Home Page',
),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
DateTime? picked;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('items').plural(1),
Text('items').plural(2),
Text('welcome').tr(gender: 'male', ),
Text('welcome').tr(gender: 'neutral',),
Text(context.translate(
'hello',
)),
SizedBox(height: 20),
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
CupertinoExpansionTile(
title: Text('Cupertino Expansion Tile'),
child: Text('Cupertino Expansion Tile Example')),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}