Skip to content

Commit 7a5b2a9

Browse files
committed
localization added
1 parent d5a73d2 commit 7a5b2a9

File tree

7 files changed

+30
-1
lines changed

7 files changed

+30
-1
lines changed

l10n.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
arb-dir: lib/l10n
2+
template-arb-file: app_en.arb
3+
output-localization-file: app_localizations.dart

lib/l10n/.gitkeep

Whitespace-only changes.

lib/l10n/app_az.arb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"hi": "Salam!"
3+
}

lib/l10n/app_en.arb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"hi": "Hi!",
3+
"@hi": {
4+
"description": "The conventional newborn programmer greeting"
5+
}
6+
}

lib/presentation/app.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_bloc/flutter_bloc.dart';
3+
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
4+
import 'package:flutter_localizations/flutter_localizations.dart';
35
import 'package:logging/logging.dart';
46

57
import '../bloc/theme/theme_cubit.dart';
68
import 'values/app_themes.dart';
9+
import 'values/supported_locales.dart';
710

811
class App extends StatelessWidget {
912
@override
@@ -15,6 +18,13 @@ class App extends StatelessWidget {
1518
themeMode: themeMode,
1619
theme: AppThemes.lightTheme,
1720
darkTheme: AppThemes.darkTheme,
21+
supportedLocales: supportedLocales,
22+
localizationsDelegates: [
23+
GlobalMaterialLocalizations.delegate,
24+
GlobalWidgetsLocalizations.delegate,
25+
GlobalCupertinoLocalizations.delegate,
26+
AppLocalizations.delegate,
27+
],
1828
home: Navigator(
1929
pages: [
2030
MaterialPage(child: DemoPage()),
@@ -60,7 +70,7 @@ class _DemoPageState extends State<DemoPage> {
6070
),
6171
body: Center(
6272
child: Text(
63-
'Welcome To\nStarter Architecture Example',
73+
AppLocalizations.of(context)!.hi,
6474
textAlign: TextAlign.center,
6575
style: Theme.of(context).textTheme.headline6,
6676
),
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import 'package:flutter/widgets.dart';
2+
3+
final supportedLocales = <Locale>[
4+
const Locale('en', 'US'),
5+
const Locale('az', 'AZ'),
6+
];

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dev_dependencies:
3131

3232

3333
flutter:
34+
generate: true
3435
uses-material-design: true
3536

3637
# To add assets to your application, add an assets section, like this:

0 commit comments

Comments
 (0)