Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Setup Internationalization
Browse files Browse the repository at this point in the history
  • Loading branch information
Hjort committed Nov 30, 2023
1 parent ea4a02b commit 829cb0e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 18 deletions.
4 changes: 4 additions & 0 deletions l10n.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
nullable-getter: false
10 changes: 10 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"initializing": "Initializing...",
"cont": "Continue",
"before_you_begin": "Before you begin",
"intro_text0": "Before you start using the Concordium Mobile Wallet, you have to set up a passcode and optionally biometrics.",
"intro_text1": "It is very important that you keep your passcode safe, because it is the only way to access your accounts. Concordium is not able to change your passcode or help you unlock your wallet if you lose your passcode.",
"read_and_agree": "I have read and agree to the ",
"terms_and_conditions": "Terms and Conditions v{v}",
"previously_accepted": " (you previously accepted v{v})."
}
20 changes: 12 additions & 8 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:concordium_wallet/theme.dart';
import 'package:concordium_wallet/types/future_value.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

void main() {
runApp(const App());
Expand Down Expand Up @@ -55,10 +56,13 @@ class App extends StatelessWidget {
child: _WithSelectedNetwork(
initialNetwork: initialNetwork,
child: _WithTermsAndConditionAcceptance(
child: MaterialApp(
routes: appRoutes,
theme: concordiumTheme(),
)),
child: MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
routes: appRoutes,
theme: concordiumTheme(),
),
),
),
);
}
Expand Down Expand Up @@ -196,14 +200,14 @@ class _Initializing extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const Column(
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircularProgressIndicator(),
SizedBox(height: 16),
const CircularProgressIndicator(),
const SizedBox(height: 16),
// Setting text direction is required because we're outside 'MaterialApp' widget.
Text('Initializing...', textDirection: TextDirection.ltr),
Text(AppLocalizations.of(context).initializing, textDirection: TextDirection.ltr),
],
);
}
Expand Down
20 changes: 10 additions & 10 deletions lib/screens/terms_and_conditions/screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:concordium_wallet/state/terms_and_conditions.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class TermsAndConditionsScreen extends StatefulWidget {
final TermsAndConditions validTermsAndConditions;
Expand Down Expand Up @@ -53,18 +54,17 @@ class _TermsAndConditionsScreenState extends State<TermsAndConditionsScreen> {
const SizedBox(height: 24),
Center(
child: Text(
'Before you begin',
AppLocalizations.of(context).before_you_begin,
style: Theme.of(context).textTheme.displaySmall,
),
),
Container(
padding: const EdgeInsets.all(16),
child: const Column(
child: Column(
children: [
Text('Before you start using the Concordium Mobile Wallet, you have to set up a passcode and optionally biometrics.'),
SizedBox(height: 9),
Text(
'It is very important that you keep your passcode safe, because it is the only way to access your accounts. Concordium is not able to change your passcode or help you unlock your wallet if you lose your passcode.'),
Text(AppLocalizations.of(context).intro_text0),
const SizedBox(height: 9),
Text(AppLocalizations.of(context).intro_text1),
],
),
),
Expand All @@ -84,9 +84,9 @@ class _TermsAndConditionsScreenState extends State<TermsAndConditionsScreen> {
text: TextSpan(
style: Theme.of(context).textTheme.bodySmall,
children: [
const TextSpan(text: 'I have read and agree to the '),
TextSpan(text: AppLocalizations.of(context).read_and_agree),
TextSpan(
text: 'Terms and Conditions v${widget.validTermsAndConditions.version}',
text: AppLocalizations.of(context).terms_and_conditions(widget.validTermsAndConditions.version),
style: const TextStyle(
color: Colors.indigo,
fontWeight: FontWeight.bold,
Expand All @@ -95,7 +95,7 @@ class _TermsAndConditionsScreenState extends State<TermsAndConditionsScreen> {
switch (widget.acceptedTermsAndConditionsVersion) {
null => const TextSpan(text: '.'),
String v => TextSpan(
text: ' (you previously accepted v$v).',
text: AppLocalizations.of(context).previously_accepted(v),
style: Theme.of(context).textTheme.bodySmall,
),
},
Expand All @@ -113,7 +113,7 @@ class _TermsAndConditionsScreenState extends State<TermsAndConditionsScreen> {
const SizedBox(height: 9),
ElevatedButton(
onPressed: _onAcceptButtonPressed(context),
child: const Text('Continue'),
child: Text(AppLocalizations.of(context).cont),
),
],
),
Expand Down
13 changes: 13 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
flutter_localizations:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_svg:
dependency: "direct main"
description:
Expand Down Expand Up @@ -392,6 +397,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.2"
intl:
dependency: "direct main"
description:
name: intl
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
url: "https://pub.dev"
source: hosted
version: "0.18.1"
io:
dependency: transitive
description:
Expand Down
4 changes: 4 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ dependencies:
package_info_plus: ^4.2.0
hive: ^2.2.3
hive_flutter: ^1.1.0
flutter_localizations:
sdk: flutter
intl: ^0.18.1

dev_dependencies:
flutter_test:
Expand All @@ -66,6 +69,7 @@ dev_dependencies:

# The following section is specific to Flutter packages.
flutter:
generate: true

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
Expand Down

0 comments on commit 829cb0e

Please sign in to comment.