mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-03 14:06:51 +08:00
Settings: Make some of the strings translatable
Man, this is going to be exhausting. There are some 165 Text instances. So this mean probably around 200+ strings.
This commit is contained in:
@ -1 +1,20 @@
|
|||||||
email: Email
|
settings:
|
||||||
|
title: Settings
|
||||||
|
author:
|
||||||
|
label: Full Name
|
||||||
|
hint: Who should author the changes?
|
||||||
|
validator: Please enter a name
|
||||||
|
email:
|
||||||
|
label: Email
|
||||||
|
hint: Email Address
|
||||||
|
validator:
|
||||||
|
empty: Please enter an email
|
||||||
|
invalid: Please enter a valid email
|
||||||
|
display:
|
||||||
|
title: Display Settings
|
||||||
|
darkTheme: Dark Theme
|
||||||
|
gitAuthor: Git Author Settings
|
||||||
|
versionInfo: Version Info
|
||||||
|
analytics: Analytics
|
||||||
|
crashReports: Collect Anonymous Crash Reports
|
||||||
|
usageStats: Collect Anonymous Usage Statistics
|
||||||
|
@ -19,7 +19,7 @@ class SettingsScreen extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Settings'),
|
title: Text(tr('settings.title')),
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: const Icon(Icons.arrow_back),
|
icon: const Icon(Icons.arrow_back),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -60,15 +60,15 @@ class SettingsListState extends State<SettingsList> {
|
|||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
key: gitAuthorKey,
|
key: gitAuthorKey,
|
||||||
style: Theme.of(context).textTheme.title,
|
style: Theme.of(context).textTheme.title,
|
||||||
decoration: const InputDecoration(
|
decoration: InputDecoration(
|
||||||
icon: Icon(Icons.person),
|
icon: Icon(Icons.person),
|
||||||
hintText: 'Who should author the changes?',
|
hintText: tr('settings.author.hint'),
|
||||||
labelText: 'Full Name',
|
labelText: tr('settings.author.label'),
|
||||||
),
|
),
|
||||||
validator: (String value) {
|
validator: (String value) {
|
||||||
value = value.trim();
|
value = value.trim();
|
||||||
if (value.isEmpty) {
|
if (value.isEmpty) {
|
||||||
return 'Please enter a name';
|
return tr('settings.author.validator');
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
@ -95,20 +95,20 @@ class SettingsListState extends State<SettingsList> {
|
|||||||
keyboardType: TextInputType.emailAddress,
|
keyboardType: TextInputType.emailAddress,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
icon: Icon(Icons.email),
|
icon: Icon(Icons.email),
|
||||||
hintText: 'Who should author the changes?',
|
hintText: tr('settings.email.hint'),
|
||||||
labelText: tr('email'),
|
labelText: tr('settings.email.label'),
|
||||||
),
|
),
|
||||||
validator: (String value) {
|
validator: (String value) {
|
||||||
value = value.trim();
|
value = value.trim();
|
||||||
if (value.isEmpty) {
|
if (value.isEmpty) {
|
||||||
return 'Please enter an email';
|
return tr('settings.email.validator.empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
bool emailValid =
|
bool emailValid =
|
||||||
RegExp(r"^[a-zA-Z0-9.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z\-]+")
|
RegExp(r"^[a-zA-Z0-9.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z\-]+")
|
||||||
.hasMatch(value);
|
.hasMatch(value);
|
||||||
if (!emailValid) {
|
if (!emailValid) {
|
||||||
return 'Please enter a valid email';
|
return tr('settings.email.validator.invalid');
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
@ -131,9 +131,9 @@ class SettingsListState extends State<SettingsList> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ListView(children: [
|
return ListView(children: [
|
||||||
SettingsHeader('Display Settings'),
|
SettingsHeader(tr('settings.display.title')),
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
title: const Text("Dark Theme"),
|
title: Text(tr('settings.display.darkTheme')),
|
||||||
value: brightness == Brightness.dark,
|
value: brightness == Brightness.dark,
|
||||||
onChanged: (bool newVal) {
|
onChanged: (bool newVal) {
|
||||||
var b = newVal ? Brightness.dark : Brightness.light;
|
var b = newVal ? Brightness.dark : Brightness.light;
|
||||||
@ -157,7 +157,7 @@ class SettingsListState extends State<SettingsList> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SettingsHeader("Git Author Settings"),
|
SettingsHeader(tr('settings.gitAuthor')),
|
||||||
ListTile(title: gitAuthorForm),
|
ListTile(title: gitAuthorForm),
|
||||||
ListTile(title: gitAuthorEmailForm),
|
ListTile(title: gitAuthorEmailForm),
|
||||||
ListTile(
|
ListTile(
|
||||||
@ -206,9 +206,9 @@ class SettingsListState extends State<SettingsList> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16.0),
|
const SizedBox(height: 16.0),
|
||||||
SettingsHeader("Analytics"),
|
SettingsHeader(tr('settings.analytics')),
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
title: const Text("Collect Anonymous Usage Statistics"),
|
title: Text(tr('settings.usageStats')),
|
||||||
value: Settings.instance.collectUsageStatistics,
|
value: Settings.instance.collectUsageStatistics,
|
||||||
onChanged: (bool val) {
|
onChanged: (bool val) {
|
||||||
Settings.instance.collectUsageStatistics = val;
|
Settings.instance.collectUsageStatistics = val;
|
||||||
@ -217,7 +217,7 @@ class SettingsListState extends State<SettingsList> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
SwitchListTile(
|
SwitchListTile(
|
||||||
title: const Text("Collect Anonymous Crash Reports"),
|
title: Text(tr('settings.crashReports')),
|
||||||
value: Settings.instance.collectCrashReports,
|
value: Settings.instance.collectCrashReports,
|
||||||
onChanged: (bool val) {
|
onChanged: (bool val) {
|
||||||
Settings.instance.collectCrashReports = val;
|
Settings.instance.collectCrashReports = val;
|
||||||
@ -274,7 +274,7 @@ class VersionNumberTileState extends State<VersionNumberTile> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var textTheme = Theme.of(context).textTheme;
|
var textTheme = Theme.of(context).textTheme;
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text("Version Info", style: textTheme.subhead),
|
title: Text(tr('settings.versionInfo'), style: textTheme.subhead),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
versionText,
|
versionText,
|
||||||
style: textTheme.body1,
|
style: textTheme.body1,
|
||||||
|
Reference in New Issue
Block a user