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

translation: Added some missing strings + devided strings into sections #746

Merged
merged 7 commits into from
Dec 23, 2021
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
726 changes: 383 additions & 343 deletions packages/smooth_app/lib/l10n/app_en.arb

Large diffs are not rendered by default.

16 changes: 0 additions & 16 deletions packages/smooth_app/lib/pages/organization_page.dart

This file was deleted.

17 changes: 9 additions & 8 deletions packages/smooth_app/lib/pages/page_manager.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:smooth_app/widgets/tab_navigator.dart';

enum BottomNavigationTab {
Expand Down Expand Up @@ -48,6 +49,7 @@ class PageManagerState extends State<PageManager> {

@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
return WillPopScope(
onWillPop: () async {
final bool isFirstRouteInCurrentTab =
Expand Down Expand Up @@ -76,19 +78,18 @@ class PageManagerState extends State<PageManager> {
_selectTab(_pageKeys[index], index);
},
currentIndex: _currentPage.index,
items: const <BottomNavigationBarItem>[
// TODO(M123): Translate
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.account_circle),
label: 'Profile',
icon: const Icon(Icons.account_circle),
label: appLocalizations.profile_navbar_label,
),
BottomNavigationBarItem(
icon: Icon(Icons.search),
label: 'Scan or Search',
icon: const Icon(Icons.search),
label: appLocalizations.scan_navbar_label,
),
BottomNavigationBarItem(
icon: Icon(Icons.history),
label: 'History',
icon: const Icon(Icons.history),
label: appLocalizations.history_navbar_label,
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class ProductListDialogHelper {
context: context,
builder: (BuildContext context) => SmoothAlertDialog(
close: false,
body: const Text(
'Do you really want to clear this list?'), // TODO(monsieurtanuki): translate
body: Text(AppLocalizations.of(context)!.really_clear),
actions: <SmoothSimpleButton>[
SmoothSimpleButton(
text: AppLocalizations.of(context)!.no,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class _ProductListPageState extends State<ProductListPage> {
PopupMenuButton<String>(
itemBuilder: (final BuildContext context) =>
<PopupMenuEntry<String>>[
const PopupMenuItem<String>(
PopupMenuItem<String>(
value: 'clear',
child: Text('Clear'), // TODO(monsieurtanuki): translate
child: Text(appLocalizations.clear),
enabled: true,
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class _ProductQueryPageState extends State<ProductQueryPage> {
ProductQueryPageHelper.getDurationStringFromTimestamp(
_lastUpdate!, context);
final String message =
'${AppLocalizations.of(context)!.chached_results_from} $lastTime';
'${AppLocalizations.of(context)!.cached_results_from} $lastTime';
_lastUpdate = null;

Future<void>.delayed(
Expand Down
3 changes: 1 addition & 2 deletions packages/smooth_app/lib/pages/product/summary_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ class _SummaryCardState extends State<SummaryCard> {
BorderRadius.vertical(bottom: SmoothCard.CIRCULAR_RADIUS),
),
child: Center(
// TODO(jasmeet): Internationalize
child: Text(
'Tap to see more info...',
AppLocalizations.of(context)!.tab_for_more,
style: Theme.of(context)
.textTheme
.bodyText1!
Expand Down
12 changes: 8 additions & 4 deletions packages/smooth_app/lib/pages/scan/continuous_scan_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';
Expand Down Expand Up @@ -123,6 +124,7 @@ class _ContinuousScanPageState extends State<ContinuousScanPage> {
}

Widget _buildButtonsRow(BuildContext context, ContinuousScanModel model) {
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
final ButtonStyle buttonStyle = ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
Expand All @@ -143,15 +145,17 @@ class _ContinuousScanPageState extends State<ContinuousScanPage> {
style: buttonStyle,
icon: const Icon(Icons.cancel_outlined),
onPressed: model.clearScanSession,
// TODO(jasmeet): Internationalize
label: const Text('Clear'),
label: Text(appLocalizations.clear),
),
ElevatedButton.icon(
style: buttonStyle,
icon: const Icon(Icons.emoji_events_outlined),
onPressed: () => _openPersonalizedRankingPage(context),
// TODO(jasmeet): Internationalize
label: Text('Compare ${model.getBarcodes().length} Products'),
label: Text(
appLocalizations.plural_compare_x_products(
model.getBarcodes().length,
),
),
),
],
),
Expand Down
4 changes: 2 additions & 2 deletions packages/smooth_app/lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class ProfilePage extends StatelessWidget {
'https://slack.openfoodfacts.org/', false),
),

//About
//About this app
SmoothListTile(
text: appLocalizations.about,
text: appLocalizations.about_this_app,
onPressed: () async {
final PackageInfo packageInfo = await PackageInfo.fromPlatform();
showDialog<void>(
Expand Down
33 changes: 17 additions & 16 deletions packages/smooth_app/lib/pages/user_management/login_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:provider/provider.dart';
import 'package:smooth_app/helpers/user_management_helper.dart';
Expand All @@ -8,7 +9,6 @@ import 'package:smooth_ui_library/widgets/smooth_text_form_field.dart';

// TODO(M123-dev): Autofill support
// TODO(M123-dev): Handle colors better
// TODO(M123-dev): internationalize everything
// TODO(M123-dev): Better validation

class LoginPage extends StatefulWidget {
Expand Down Expand Up @@ -69,6 +69,7 @@ class _LoginPageState extends State<LoginPage> {
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
final ThemeProvider themeProvider = context.watch<ThemeProvider>();
final AppLocalizations appLocalizations = AppLocalizations.of(context)!;
final Size size = MediaQuery.of(context).size;

// Needs to be changed
Expand Down Expand Up @@ -97,7 +98,7 @@ class _LoginPageState extends State<LoginPage> {
const Spacer(flex: 4),

Text(
'Sign in to your Open Food Facts account to save your contributions ',
appLocalizations.sign_in_text,
textAlign: TextAlign.center,
style: theme.textTheme.headline1?.copyWith(
fontSize: 20.0,
Expand All @@ -108,13 +109,13 @@ class _LoginPageState extends State<LoginPage> {

const Spacer(flex: 8),

if (_wrongCredentials) ...const <Widget>[
if (_wrongCredentials) ...<Widget>[
SmoothCard(
padding: EdgeInsets.all(10.0),
padding: const EdgeInsets.all(10.0),
color: Colors.red,
child: Text('Incorrect user name or password.'),
child: Text(appLocalizations.incorrect_credentials),
),
Spacer(
const Spacer(
flex: 1,
)
],
Expand All @@ -123,15 +124,15 @@ class _LoginPageState extends State<LoginPage> {
SmoothTextFormField(
type: TextFieldTypes.PLAIN_TEXT,
controller: userIdController,
hintText: 'Login',
hintText: appLocalizations.login,
textColor: customGrey,
backgroundColor: textFieldBackgroundColor,
prefixIcon: const Icon(Icons.person),
enabled: !_runningQuery,
textInputAction: TextInputAction.next, // Moves focus to next.
validator: (String? value) {
if (value == null || value.isEmpty) {
return 'Please enter some text';
return appLocalizations.enter_some_text;
}
return null;
},
Expand All @@ -143,15 +144,15 @@ class _LoginPageState extends State<LoginPage> {
SmoothTextFormField(
type: TextFieldTypes.PASSWORD,
controller: passwordController,
hintText: 'Password',
hintText: appLocalizations.password,
textColor: customGrey,
backgroundColor: textFieldBackgroundColor,
prefixIcon: const Icon(Icons.vpn_key),
enabled: !_runningQuery,
textInputAction: TextInputAction.done, // Hides the keyboard
validator: (String? value) {
if (value == null || value.isEmpty) {
return 'Please enter some text';
return appLocalizations.enter_some_text;
}
return null;
},
Expand All @@ -163,7 +164,7 @@ class _LoginPageState extends State<LoginPage> {
ElevatedButton(
onPressed: () => _login(context),
child: Text(
'Sign in',
appLocalizations.sign_in,
style: theme.textTheme.bodyText2?.copyWith(
fontSize: 18.0,
color: theme.colorScheme.onSurface,
Expand All @@ -184,13 +185,13 @@ class _LoginPageState extends State<LoginPage> {
//Forgot password
TextButton(
onPressed: () {
const SnackBar snackBar = SnackBar(
content: Text('Not implemented yet'),
final SnackBar snackBar = SnackBar(
content: Text(appLocalizations.featureInProgress),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
child: Text(
'Forgot password',
appLocalizations.forgot_password,
style: theme.textTheme.bodyText2?.copyWith(
fontSize: 18.0,
color: theme.colorScheme.primary,
Expand All @@ -205,8 +206,8 @@ class _LoginPageState extends State<LoginPage> {
height: size.height * 0.06,
child: OutlinedButton(
onPressed: () {
const SnackBar snackBar = SnackBar(
content: Text('Not implemented yet'),
final SnackBar snackBar = SnackBar(
content: Text(appLocalizations.featureInProgress),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class UserContributionView extends StatelessWidget {
//Develop
SmoothListTile(
text: AppLocalizations.of(context)!
.contribute_develop,
.contribute_sw_development,
onPressed: () => _develop(context),
),

Expand Down Expand Up @@ -131,7 +131,7 @@ class UserContributionView extends StatelessWidget {
context: context,
builder: (BuildContext context) {
return SmoothAlertDialog(
title: AppLocalizations.of(context)!.contribute_develop,
title: AppLocalizations.of(context)!.contribute_sw_development,
body: Column(
children: <Widget>[
Text(
Expand Down