2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 02:05:29 +00:00

Refactor of translation lookup!

This commit is contained in:
Oliver Walters
2021-05-19 23:33:28 +10:00
parent b86025013d
commit 2a3e83509f
26 changed files with 339 additions and 353 deletions

View File

@ -6,9 +6,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:package_info/package_info.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:package_info/package_info.dart';
import 'package:InvenTree/l10.dart';
class InvenTreeAboutWidget extends StatelessWidget {
@ -45,7 +44,7 @@ class InvenTreeAboutWidget extends StatelessWidget {
tiles.add(
ListTile(
title: Text(
I18N.of(context).serverDetails,
L10().serverDetails,
style: TextStyle(fontWeight: FontWeight.bold),
),
)
@ -54,33 +53,33 @@ class InvenTreeAboutWidget extends StatelessWidget {
if (InvenTreeAPI().isConnected()) {
tiles.add(
ListTile(
title: Text(I18N.of(context).address),
subtitle: Text(InvenTreeAPI().baseUrl.isNotEmpty ? InvenTreeAPI().baseUrl : I18N.of(context).notConnected),
title: Text(L10().address),
subtitle: Text(InvenTreeAPI().baseUrl.isNotEmpty ? InvenTreeAPI().baseUrl : L10().notConnected),
leading: FaIcon(FontAwesomeIcons.globe),
)
);
tiles.add(
ListTile(
title: Text(I18N.of(context).version),
subtitle: Text(InvenTreeAPI().version.isNotEmpty ? InvenTreeAPI().version : I18N.of(context).notConnected),
title: Text(L10().version),
subtitle: Text(InvenTreeAPI().version.isNotEmpty ? InvenTreeAPI().version : L10().notConnected),
leading: FaIcon(FontAwesomeIcons.infoCircle),
)
);
tiles.add(
ListTile(
title: Text(I18N.of(context).serverInstance),
subtitle: Text(InvenTreeAPI().instance.isNotEmpty ? InvenTreeAPI().instance : I18N.of(context).notConnected),
title: Text(L10().serverInstance),
subtitle: Text(InvenTreeAPI().instance.isNotEmpty ? InvenTreeAPI().instance : L10().notConnected),
leading: FaIcon(FontAwesomeIcons.server),
)
);
} else {
tiles.add(
ListTile(
title: Text(I18N.of(context).notConnected),
title: Text(L10().notConnected),
subtitle: Text(
I18N.of(context).serverNotConnected,
L10().serverNotConnected,
style: TextStyle(fontStyle: FontStyle.italic),
),
leading: FaIcon(FontAwesomeIcons.exclamationCircle)
@ -91,7 +90,7 @@ class InvenTreeAboutWidget extends StatelessWidget {
tiles.add(
ListTile(
title: Text(
I18N.of(context).appDetails,
L10().appDetails,
style: TextStyle(fontWeight: FontWeight.bold),
),
)
@ -99,7 +98,7 @@ class InvenTreeAboutWidget extends StatelessWidget {
tiles.add(
ListTile(
title: Text(I18N.of(context).packageName),
title: Text(L10().packageName),
subtitle: Text("${info.packageName}"),
leading: FaIcon(FontAwesomeIcons.box)
)
@ -107,7 +106,7 @@ class InvenTreeAboutWidget extends StatelessWidget {
tiles.add(
ListTile(
title: Text(I18N.of(context).version),
title: Text(L10().version),
subtitle: Text("${info.version}"),
leading: FaIcon(FontAwesomeIcons.infoCircle)
)
@ -115,8 +114,8 @@ class InvenTreeAboutWidget extends StatelessWidget {
tiles.add(
ListTile(
title: Text(I18N.of(context).releaseNotes),
subtitle: Text(I18N.of(context).appReleaseNotes),
title: Text(L10().releaseNotes),
subtitle: Text(L10().appReleaseNotes),
leading: FaIcon(FontAwesomeIcons.fileAlt),
onTap: () {
_releaseNotes(context);
@ -126,8 +125,8 @@ class InvenTreeAboutWidget extends StatelessWidget {
tiles.add(
ListTile(
title: Text(I18N.of(context).credits),
subtitle: Text(I18N.of(context).appCredits),
title: Text(L10().credits),
subtitle: Text(L10().appCredits),
leading: FaIcon(FontAwesomeIcons.bullhorn),
onTap: () {
_credits(context);
@ -137,7 +136,7 @@ class InvenTreeAboutWidget extends StatelessWidget {
return Scaffold(
appBar: AppBar(
title: Text(I18N.of(context).appAbout),
title: Text(L10().appAbout),
),
body: ListView(
children: ListTile.divideTiles(

View File

@ -2,7 +2,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:InvenTree/app_settings.dart';
@ -82,21 +83,21 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
return Scaffold(
key: _settingsKey,
appBar: AppBar(
title: Text(I18N.of(context).appSettings),
title: Text(L10().appSettings),
),
body: Container(
child: ListView(
children: [
ListTile(
title: Text(
I18N.of(context).parts,
L10().parts,
style: TextStyle(fontWeight: FontWeight.bold),
),
leading: FaIcon(FontAwesomeIcons.shapes),
),
ListTile(
title: Text(I18N.of(context).includeSubcategories),
subtitle: Text(I18N.of(context).includeSubcategoriesDetail),
title: Text(L10().includeSubcategories),
subtitle: Text(L10().includeSubcategoriesDetail),
leading: FaIcon(FontAwesomeIcons.sitemap),
trailing: Switch(
value: partSubcategory,
@ -105,14 +106,14 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
),
Divider(height: 3),
ListTile(
title: Text(I18N.of(context).stock,
title: Text(L10().stock,
style: TextStyle(fontWeight: FontWeight.bold),
),
leading: FaIcon(FontAwesomeIcons.boxes),
),
ListTile(
title: Text(I18N.of(context).includeSublocations),
subtitle: Text(I18N.of(context).includeSublocationsDetail),
title: Text(L10().includeSublocations),
subtitle: Text(L10().includeSublocationsDetail),
leading: FaIcon(FontAwesomeIcons.sitemap),
trailing: Switch(
value: stockSublocation,
@ -122,14 +123,14 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
Divider(height: 3),
ListTile(
title: Text(
I18N.of(context).sounds,
L10().sounds,
style: TextStyle(fontWeight: FontWeight.bold),
),
leading: FaIcon(FontAwesomeIcons.volumeUp),
),
ListTile(
title: Text(I18N.of(context).serverError),
subtitle: Text(I18N.of(context).soundOnServerError),
title: Text(L10().serverError),
subtitle: Text(L10().soundOnServerError),
leading: FaIcon(FontAwesomeIcons.server),
trailing: Switch(
value: serverSounds,
@ -137,8 +138,8 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
),
),
ListTile(
title: Text(I18N.of(context).barcodeTones),
subtitle: Text(I18N.of(context).soundOnBarcodeAction),
title: Text(L10().barcodeTones),
subtitle: Text(L10().soundOnBarcodeAction),
leading: FaIcon(FontAwesomeIcons.qrcode),
trailing: Switch(
value: barcodeSounds,

View File

@ -3,9 +3,10 @@ import 'package:InvenTree/widget/fields.dart';
import 'package:InvenTree/widget/spinner.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:InvenTree/l10.dart';
import '../api.dart';
import '../preferences.dart';
import '../user_profile.dart';
@ -53,7 +54,7 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
}
showFormDialog(
createNew ? I18N.of(context).profileAdd : I18N.of(context).profileEdit,
createNew ? L10().profileAdd : L10().profileEdit,
key: _addProfileKey,
callback: () {
if (createNew) {
@ -79,29 +80,29 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
},
fields: <Widget> [
StringField(
label: I18N.of(context).name,
label: L10().name,
hint: "Enter profile name",
initial: createNew ? '' : profile.name,
onSaved: (value) => _name = value,
validator: _validateProfileName,
),
StringField(
label: I18N.of(context).server,
label: L10().server,
hint: "http[s]://<server>:<port>",
initial: createNew ? '' : profile.server,
validator: _validateServer,
onSaved: (value) => _server = value,
),
StringField(
label: I18N.of(context).username,
hint: I18N.of(context).enterPassword,
label: L10().username,
hint: L10().enterPassword,
initial: createNew ? '' : profile.username,
onSaved: (value) => _username = value,
validator: _validateUsername,
),
StringField(
label: I18N.of(context).password,
hint: I18N.of(context).enterUsername,
label: L10().password,
hint: L10().enterUsername,
initial: createNew ? '' : profile.password,
onSaved: (value) => _password = value,
validator: _validatePassword,
@ -266,28 +267,28 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
Navigator.of(context).pop();
_selectProfile(context, profile);
},
child: Text(I18N.of(context).profileConnect),
child: Text(L10().profileConnect),
),
SimpleDialogOption(
onPressed: () {
Navigator.of(context).pop();
_editProfile(context, userProfile: profile);
},
child: Text(I18N.of(context).profileEdit),
child: Text(L10().profileEdit),
),
SimpleDialogOption(
onPressed: () {
Navigator.of(context).pop();
// Navigator.of(context, rootNavigator: true).pop();
confirmationDialog(
I18N.of(context).delete,
I18N.of(context).profileDelete + "?",
L10().delete,
L10().profileDelete + "?",
onAccept: () {
_deleteProfile(profile);
}
);
},
child: Text(I18N.of(context).profileDelete),
child: Text(L10().profileDelete),
)
],
);
@ -300,7 +301,7 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
// No profile available!
children.add(
ListTile(
title: Text(I18N.of(context).profileNone),
title: Text(L10().profileNone),
)
);
}
@ -308,7 +309,7 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
return Scaffold(
key: _loginKey,
appBar: AppBar(
title: Text(I18N.of(context).profileSelect),
title: Text(L10().profileSelect),
),
body: Container(
child: ListView(

View File

@ -2,8 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:markdown/markdown.dart' as md;
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
class ReleaseNotesWidget extends StatelessWidget {
@ -16,7 +15,7 @@ class ReleaseNotesWidget extends StatelessWidget {
Widget build (BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(I18N.of(context).releaseNotes)
title: Text(L10().releaseNotes)
),
body: Markdown(
selectable: false,
@ -37,7 +36,7 @@ class CreditsWidget extends StatelessWidget {
Widget build (BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(I18N.of(context).credits),
title: Text(L10().credits),
),
body: Markdown(
selectable: false,

View File

@ -7,7 +7,8 @@ import 'package:InvenTree/widget/dialogs.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/l10.dart';
import 'package:url_launcher/url_launcher.dart';
import 'login.dart';
@ -35,7 +36,7 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
title: Text(I18N.of(context).settings),
title: Text(L10().settings),
),
body: Center(
child: ListView(
@ -43,26 +44,26 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
context: context,
tiles: <Widget>[
ListTile(
title: Text(I18N.of(context).server),
subtitle: Text(I18N.of(context).configureServer),
title: Text(L10().server),
subtitle: Text(L10().configureServer),
leading: FaIcon(FontAwesomeIcons.server),
onTap: _editServerSettings,
),
ListTile(
leading: FaIcon(FontAwesomeIcons.cogs),
title: Text(I18N.of(context).appSettings),
subtitle: Text(I18N.of(context).appSettingsDetails),
title: Text(L10().appSettings),
subtitle: Text(L10().appSettingsDetails),
onTap: _editAppSettings,
),
ListTile(
title: Text(I18N.of(context).about),
subtitle: Text(I18N.of(context).appDetails),
title: Text(L10().about),
subtitle: Text(L10().appDetails),
leading: FaIcon(FontAwesomeIcons.infoCircle),
onTap: _about,
),
ListTile(
title: Text(I18N.of(context).documentation),
title: Text(L10().documentation),
subtitle: Text("https://inventree.readthedocs.io"),
leading: FaIcon(FontAwesomeIcons.book),
onTap: () {
@ -71,8 +72,8 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
),
ListTile(
title: Text(I18N.of(context).feedback),
subtitle: Text(I18N.of(context).submitFeedback),
title: Text(L10().feedback),
subtitle: Text(L10().submitFeedback),
leading: FaIcon(FontAwesomeIcons.comments),
onTap: () {
_submitFeedback(context);
@ -115,12 +116,12 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
if (result) {
showSnackIcon(
I18N.of(context).feedbackSuccess,
L10().feedbackSuccess,
success: true,
);
} else {
showSnackIcon(
I18N.of(context).feedbackError,
L10().feedbackError,
success: false,
);
}
@ -133,7 +134,7 @@ class _InvenTreeSettingsState extends State<InvenTreeSettingsWidget> {
_controller.clear();
showFormDialog(
I18N.of(context).submitFeedback,
L10().submitFeedback,
key: _feedbackKey,
callback: () {
_sendReport(context, _controller.text);