diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 6c54137..901a21e 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -1,68 +1,73 @@
-
- CFBundleDevelopmentRegion
- $(DEVELOPMENT_LANGUAGE)
- CFBundleDisplayName
- Counter Workshop
- CFBundleExecutable
- $(EXECUTABLE_NAME)
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- counter_workshop
- CFBundlePackageType
- APPL
- CFBundleShortVersionString
- $(FLUTTER_BUILD_NAME)
- CFBundleSignature
- ????
- CFBundleVersion
- $(FLUTTER_BUILD_NUMBER)
- LSRequiresIPhoneOS
-
- UILaunchStoryboardName
- LaunchScreen
- UIMainStoryboardFile
- Main
- UISupportedInterfaceOrientations
-
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
-
- UISupportedInterfaceOrientations~ipad
-
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationPortraitUpsideDown
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
-
- UIViewControllerBasedStatusBarAppearance
-
- CADisableMinimumFrameDurationOnPhone
-
- UIApplicationSupportsIndirectInputEvents
-
-
- FlutterDeepLinkingEnabled
-
- CFBundleURLTypes
-
-
- CFBundleTypeRole
- Editor
- CFBundleURLName
- counter.de
- CFBundleURLSchemes
-
- de.coodoo.counter
- counter
-
-
-
-
-
+
+ CFBundleDevelopmentRegion
+ $(DEVELOPMENT_LANGUAGE)
+ CFBundleDisplayName
+ Counter Workshop
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIdentifier
+ $(PRODUCT_BUNDLE_IDENTIFIER)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ counter_workshop
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ $(FLUTTER_BUILD_NAME)
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ $(FLUTTER_BUILD_NUMBER)
+ LSRequiresIPhoneOS
+
+ UILaunchStoryboardName
+ LaunchScreen
+ UIMainStoryboardFile
+ Main
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UISupportedInterfaceOrientations~ipad
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UIViewControllerBasedStatusBarAppearance
+
+ CADisableMinimumFrameDurationOnPhone
+
+ UIApplicationSupportsIndirectInputEvents
+
+
+ FlutterDeepLinkingEnabled
+
+ CFBundleURLTypes
+
+
+ CFBundleTypeRole
+ Editor
+ CFBundleURLName
+ counter.de
+ CFBundleURLSchemes
+
+ de.coodoo.counter
+ counter
+
+ CFBundleLocalizations
+
+ en
+ de
+
+
+
+
+
\ No newline at end of file
diff --git a/l10n.yaml b/l10n.yaml
new file mode 100644
index 0000000..9772ffa
--- /dev/null
+++ b/l10n.yaml
@@ -0,0 +1,4 @@
+arb-dir: lib/src/core/localization # Where to find translation files
+template-arb-file: app_en.arb # Which translation is the default/template
+output-localization-file: app_localizations.dart # What to call generated dart files
+nullable-getter: false
diff --git a/lib/main.dart b/lib/main.dart
index 847b865..9274c45 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -2,8 +2,11 @@ import 'package:counter_workshop/src/app.dart';
import 'package:counter_workshop/src/features/counter/data/datasources/remote/src/mock/counter_fake.api.dart';
import 'package:counter_workshop/src/features/counter/data/repositories/counter.repository.dart';
import 'package:flutter/material.dart';
+import 'package:intl/intl.dart';
+import 'package:intl/intl_standalone.dart' if (dart.library.html) 'package:intl/intl_browser.dart';
-void main() {
+Future main() async {
+ Intl.systemLocale = await findSystemLocale();
final CounterRepository counterRepository = CounterRepository(counterApi: CounterFakeApi());
runApp(
App(
diff --git a/lib/src/app.dart b/lib/src/app.dart
index a494fd0..c76d605 100644
--- a/lib/src/app.dart
+++ b/lib/src/app.dart
@@ -5,6 +5,7 @@ import 'package:counter_workshop/src/features/counter/presentation/dashboard/blo
import 'package:counter_workshop/src/features/counter/presentation/dashboard/bloc/dashboard.event.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class App extends StatefulWidget {
const App({required this.counterRepository, super.key});
@@ -53,6 +54,8 @@ class AppView extends StatelessWidget {
routeInformationProvider: router.routeInformationProvider,
routeInformationParser: router.routeInformationParser,
routerDelegate: router.routerDelegate,
+ localizationsDelegates: AppLocalizations.localizationsDelegates,
+ supportedLocales: AppLocalizations.supportedLocales,
);
}
}
diff --git a/lib/src/core/extensions/localization.extension.dart b/lib/src/core/extensions/localization.extension.dart
new file mode 100644
index 0000000..02ab7f8
--- /dev/null
+++ b/lib/src/core/extensions/localization.extension.dart
@@ -0,0 +1,6 @@
+import 'package:flutter/widgets.dart';
+import 'package:flutter_gen/gen_l10n/app_localizations.dart';
+
+extension LocalizationExtension on BuildContext {
+ AppLocalizations get loc => AppLocalizations.of(this);
+}
diff --git a/lib/src/core/localization/app_de.arb b/lib/src/core/localization/app_de.arb
new file mode 100644
index 0000000..0d88e03
--- /dev/null
+++ b/lib/src/core/localization/app_de.arb
@@ -0,0 +1,4 @@
+{
+ "@@locale": "de",
+ "appTitle": "Zähler"
+}
diff --git a/lib/src/core/localization/app_en.arb b/lib/src/core/localization/app_en.arb
new file mode 100644
index 0000000..42ec6f6
--- /dev/null
+++ b/lib/src/core/localization/app_en.arb
@@ -0,0 +1,7 @@
+{
+ "@@locale": "en",
+ "appTitle": "Counter",
+ "@appTitle": {
+ "description": "Name of the app"
+ }
+}
diff --git a/lib/src/features/counter/presentation/dashboard/view/dashboard.page.dart b/lib/src/features/counter/presentation/dashboard/view/dashboard.page.dart
index 0e3d57a..9433ae0 100644
--- a/lib/src/features/counter/presentation/dashboard/view/dashboard.page.dart
+++ b/lib/src/features/counter/presentation/dashboard/view/dashboard.page.dart
@@ -1,3 +1,4 @@
+import 'package:counter_workshop/src/core/extensions/localization.extension.dart';
import 'package:counter_workshop/src/core/widgets/error_message.widget.dart';
import 'package:counter_workshop/src/features/counter/presentation/dashboard/bloc/dashboard.bloc.dart';
import 'package:counter_workshop/src/features/counter/presentation/dashboard/bloc/dashboard.state.dart';
@@ -15,7 +16,7 @@ class DashboardPage extends StatelessWidget {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
- title: const Text('Counter Page'),
+ title: Text(context.loc.appTitle),
),
body: BlocBuilder(
builder: (context, state) {
diff --git a/pubspec.lock b/pubspec.lock
index a72db10..9112bda 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -209,6 +209,11 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
+ flutter_localizations:
+ dependency: "direct main"
+ description: flutter
+ source: sdk
+ version: "0.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -268,6 +273,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.1"
+ intl:
+ dependency: "direct main"
+ description:
+ name: intl
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.17.0"
io:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 43377bb..a998cab 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -11,7 +11,9 @@ environment:
dependencies:
flutter:
sdk: flutter
-
+ flutter_localizations:
+ sdk: flutter
+ intl: ^0.17.0
cupertino_icons: ^1.0.2
equatable: ^2.0.5
http: ^0.13.5
@@ -27,7 +29,8 @@ dev_dependencies:
flutter:
uses-material-design: true
-
+ generate: true # Enable generation of localized Strings from arb files
+
fonts:
- family: VarelaRound
fonts:
@@ -37,4 +40,4 @@ flutter:
- assets/images/ # .png/.jpg images
- assets/icons/ # .svg icons
- assets/fonts/ # Custom Fonts
- - assets/launcher_icon/ # App icon image to generate from
\ No newline at end of file
+ - assets/launcher_icon/ # App icon image to generate from