Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile App: Luganda Translations #1812

Merged
merged 5 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added mobile/assets/images/uganda_flag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions mobile/lib/constants/language_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
import 'package:shared_preferences/shared_preferences.dart';
import 'package:app/services/services.dart';

const String LANGUAGE_CODE = 'languageCode';

//languages code
const String english = 'en';
const String french = 'fr';
const String portuguese = 'pt';
const String swahili = 'sw';
const String luganda = 'lg';

Future<Locale> setLocale(String languageCode) async {
SharedPreferences prefs = await SharedPreferencesHelper.instance;
await prefs.setString(LANGUAGE_CODE, languageCode);
await prefs.setString('languageCode', languageCode);

Check warning on line 15 in mobile/lib/constants/language_constants.dart

View check run for this annotation

Codecov / codecov/patch

mobile/lib/constants/language_constants.dart#L15

Added line #L15 was not covered by tests
return _locale(languageCode);
}

Future<Locale> getLocale() async {
SharedPreferences prefs = await SharedPreferencesHelper.instance;
String languageCode = prefs.getString(LANGUAGE_CODE) ?? english;
String languageCode = prefs.getString('languageCode') ?? english;

Check warning on line 21 in mobile/lib/constants/language_constants.dart

View check run for this annotation

Codecov / codecov/patch

mobile/lib/constants/language_constants.dart#L21

Added line #L21 was not covered by tests
return _locale(languageCode);
}

Expand All @@ -32,6 +32,8 @@
return const Locale(portuguese, "");
case swahili:
return const Locale(swahili, "");
case luganda:

Check warning on line 35 in mobile/lib/constants/language_constants.dart

View check run for this annotation

Codecov / codecov/patch

mobile/lib/constants/language_constants.dart#L35

Added line #L35 was not covered by tests
return const Locale(luganda, "");

default:
return const Locale(english, '');
Expand All @@ -56,6 +58,8 @@
"pt"),
Language(
4, Image.asset('assets/images/swahili_flag.png'), "Swahili", "sw"),
Language(
5, Image.asset('assets/images/uganda_flag.png'), "Luganda", "lg"),

Check warning on line 62 in mobile/lib/constants/language_constants.dart

View check run for this annotation

Codecov / codecov/patch

mobile/lib/constants/language_constants.dart#L61-L62

Added lines #L61 - L62 were not covered by tests
];
}
}
347 changes: 347 additions & 0 deletions mobile/lib/l10n/app_lg.arb

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions mobile/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:app/main_common.dart';
import 'package:app/models/models.dart';
import 'package:app/services/widget_service.dart';
import 'package:app/themes/theme.dart';
import 'package:app/utils/custom_localisation.dart';
import 'package:app/widgets/widgets.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_dynamic_links/firebase_dynamic_links.dart';
Expand Down Expand Up @@ -72,12 +73,17 @@ void main() async {
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
LgMaterialLocalizations.delegate,
LgCupertinoLocalizations.delegate,
LgWidgetsLocalizations.delegate,

],
supportedLocales: const [
Locale('en'), // English
Locale('fr'), //French
Locale('pt'), //Portuguese
Locale('sw'), //Swahili
Locale('lg'), //Luganda
],
home: AppCrushWidget(exception, stackTrace),
),
Expand Down
5 changes: 5 additions & 0 deletions mobile/lib/main_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:hydrated_bloc/hydrated_bloc.dart';
import 'package:path_provider/path_provider.dart';
import 'package:app/utils/custom_localisation.dart';

class AirQoApp extends StatefulWidget {
const AirQoApp(this.initialLink, {super.key, required this.locale});
Expand Down Expand Up @@ -139,12 +140,16 @@ class _AirQoAppState extends State<AirQoApp> {
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
LgMaterialLocalizations.delegate,
LgCupertinoLocalizations.delegate,
LgWidgetsLocalizations.delegate,
],
supportedLocales: const [
Locale('en'), //English
Locale('fr'), //French
Locale('pt'), //Portuguese
Locale('sw'), //Swahili
Locale('lg'), //Luganda
],
navigatorKey: navigatorKey,
navigatorObservers: [
Expand Down
10 changes: 1 addition & 9 deletions mobile/lib/screens/analytics/analytics_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,7 @@
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Container(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context)
.size
.width /
3.2,
),
child: Text(
Text(

Check warning on line 256 in mobile/lib/screens/analytics/analytics_widgets.dart

View check run for this annotation

Codecov / codecov/patch

mobile/lib/screens/analytics/analytics_widgets.dart#L256

Added line #L256 was not covered by tests
airQualityReading.dateTime
.analyticsCardString(context),
maxLines: 1,
Expand All @@ -270,7 +263,6 @@
color:
Colors.black.withOpacity(0.3),
),
),
),
const SizedBox(
width: 4.0,
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/screens/profile/profile_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@
? Colors.transparent
: CustomColors.appColorBlue,
),
child: Text(
child: AutoSizeText(

Check warning on line 860 in mobile/lib/screens/profile/profile_widgets.dart

View check run for this annotation

Codecov / codecov/patch

mobile/lib/screens/profile/profile_widgets.dart#L860

Added line #L860 was not covered by tests
AppLocalizations.of(context)!.save,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.titleSmall?.copyWith(
Expand Down
Loading
Loading