Skip to content

Commit f9199f4

Browse files
authored
fix: Hardcoded strings → localization files (#14)
1 parent b47763c commit f9199f4

File tree

3 files changed

+88
-50
lines changed

3 files changed

+88
-50
lines changed

assets/translations/app_en.arb

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
11
{
2+
"account": "Account",
3+
"accountDescription": "Manage your AniList, MAL, and Discord accounts effortlessly",
4+
"theme": "Theme",
5+
"themeDescription": "Customize the appearance and vibe of your app",
6+
"common": "Common",
7+
"commonDescription": "Access general settings for seamless app usage",
8+
"anime": "Anime",
9+
"animeDescription": "Personalize and manage your anime preferences",
10+
"manga": "Manga",
11+
"mangaDescription": "Organize and tailor your manga experience",
12+
"extensions": "Extensions",
13+
"extensionsDescription": "Install and manage extensions for added functionality",
14+
"addons": "Add-ons",
15+
"addonsDescription": "Explore additional features to enhance your app",
16+
"notifications": "Notifications",
17+
"notificationsDescription": "Configure how and when you receive notifications",
18+
"about": "About",
19+
"aboutDescription": "Learn more about the app and its creators",
20+
"supportMaintainer": "Want to support Dantotsu's Maintainer?\nConsider Donating",
21+
"donationGoal": "No donation goal atm",
22+
23+
"darkMode": "Dark Mode",
224
"enableDarkMode": "Enable Dark Mode",
3-
}
25+
"oledThemeVariant": "OLED theme Variant",
26+
"oledThemeVariantDescription": "Enable OLED Mode",
27+
"materialYou": "Material You",
28+
"materialYouDescription": "Use the same color as your wallpaper",
29+
"customTheme": "Custom theme",
30+
"customThemeDescription": "Use your own color for the theme",
31+
"colorPicker": "Color Picker",
32+
"colorPickerDescription": "Choose a color",
33+
"manageAnimeLayouts": "Manage Layouts on Anime Page",
34+
"manageAnimeLayoutsDescription": "Does not belong here",
35+
"manageMangaLayouts": "Manage Layouts on Manga Page",
36+
"manageMangaLayoutsDescription": "Does not belong here",
37+
"manageHomeLayouts": "Manage Layouts on Home Page",
38+
"manageHomeLayoutsDescription": "Does not belong here",
39+
"ok": "OK",
40+
"cancel": "Cancel"
41+
}

lib/Screens/Settings/SettingsScreen.dart

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:icons_plus/icons_plus.dart';
88
import '../../Adaptor/Settings/SettingsAdaptor.dart';
99
import '../../DataClass/Setting.dart';
1010
import '../../Functions/Function.dart';
11+
import '../../Theme/LanguageSwitcher.dart';
1112

1213
class SettingsScreen extends StatefulWidget {
1314
const SettingsScreen({super.key});
@@ -44,72 +45,72 @@ class SettingsScreenState extends BaseSettingsScreen {
4445
return [
4546
Setting(
4647
type: SettingType.normal,
47-
name: 'Account',
48-
description: 'Anilist, MAL and Discord.\nWhat more could you need?',
48+
name: getString.account,
49+
description: getString.accountDescription,
4950
icon: Icons.person,
5051
onClick: () => navigateToPage(context, const SettingsAccountScreen()),
5152
isActivity: true,
5253
),
5354
Setting(
5455
type: SettingType.normal,
55-
name: 'Theme',
56-
description: 'Change the vibe of your app',
56+
name: getString.theme,
57+
description: getString.themeDescription,
5758
icon: Icons.palette_outlined,
5859
onClick: () => navigateToPage(context, const SettingsThemeScreen()),
5960
isActivity: true,
6061
),
6162
Setting(
6263
type: SettingType.normal,
63-
name: 'Common',
64-
description: 'Change the vibe of your app',
64+
name: getString.common,
65+
description: getString.commonDescription,
6566
icon: Icons.lightbulb_outline,
6667
onClick: () {},
6768
isActivity: true,
6869
),
6970
Setting(
7071
type: SettingType.normal,
71-
name: 'Anime',
72-
description: 'Change the vibe of your app',
72+
name: getString.anime,
73+
description: getString.animeDescription,
7374
icon: Icons.movie_filter_rounded,
7475
onClick: () {},
7576
isActivity: true,
7677
),
7778
Setting(
7879
type: SettingType.normal,
79-
name: 'Manga',
80-
description: 'Change the vibe of your app',
80+
name: getString.manga,
81+
description: getString.mangaDescription,
8182
icon: Icons.import_contacts,
8283
onClick: () {},
8384
isActivity: true,
8485
),
8586
Setting(
8687
type: SettingType.normal,
87-
name: 'Extensions',
88-
description: 'Change the vibe of your app',
88+
name: getString.extensions,
89+
description: getString.extensionsDescription,
8990
icon: Icons.extension,
9091
onClick: () {},
9192
isActivity: true,
9293
),
9394
Setting(
9495
type: SettingType.normal,
95-
name: 'Add-ons',
96-
description: 'Change the vibe of your app',
96+
name: getString.addons,
97+
description: getString.addonsDescription,
9798
icon: Icons.restaurant,
9899
onClick: () {},
99100
isActivity: true,
100101
),
101102
Setting(
102103
type: SettingType.normal,
103-
name: 'Notifications',
104-
description: 'Change the vibe of your app',
104+
name: getString.notifications,
105+
description: getString.notificationsDescription,
105106
icon: Icons.notifications_none,
106107
onClick: () {},
107108
isActivity: true,
108109
),
109110
Setting(
110111
type: SettingType.normal,
111-
name: 'About',
112-
description: 'Change the vibe of your app',
112+
name: getString.about,
113+
description: getString.aboutDescription,
113114
icon: Icons.info,
114115
onClick: () {},
115116
isActivity: true,
@@ -122,7 +123,7 @@ class SettingsScreenState extends BaseSettingsScreen {
122123
return Column(
123124
children: [
124125
Text(
125-
'Want to support Dantotsu\'s Maintainer?\nConsider Donating',
126+
getString.supportMaintainer,
126127
textAlign: TextAlign.center,
127128
style: TextStyle(
128129
fontFamily: 'Poppins',
@@ -146,10 +147,10 @@ class SettingsScreenState extends BaseSettingsScreen {
146147
),
147148
),
148149
const SizedBox(height: 16),
149-
const Text(
150-
'No donation goal atm',
150+
Text(
151+
getString.donationGoal,
151152
textAlign: TextAlign.center,
152-
style: TextStyle(
153+
style: const TextStyle(
153154
fontFamily: 'Poppins',
154155
fontSize: 14,
155156
color: Colors.grey,
@@ -179,8 +180,7 @@ class SettingsScreenState extends BaseSettingsScreen {
179180
color: Colors.grey.shade800,
180181
iconSize: 38,
181182
icon: const Icon(Icons.telegram_sharp),
182-
onPressed: () =>
183-
openLinkInBrowser('https://t.me/Dartotsu'),
183+
onPressed: () => openLinkInBrowser('https://t.me/Dartotsu'),
184184
),
185185
],
186186
),

lib/Screens/Settings/SettingsThemeScreen.dart

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class SettingsThemeScreenState extends BaseSettingsScreen {
5454
return [
5555
Setting(
5656
type: SettingType.switchType,
57-
name: getString.enableDarkMode,
58-
description: 'Enable Dark Mode',
57+
name: getString.darkMode,
58+
description: getString.enableDarkMode,
5959
icon: Icons.dark_mode,
6060
isChecked: themeNotifier.isDarkMode,
6161
onSwitchChange: (bool value) async {
@@ -64,8 +64,8 @@ class SettingsThemeScreenState extends BaseSettingsScreen {
6464
),
6565
Setting(
6666
type: SettingType.switchType,
67-
name: 'OLED theme Variant',
68-
description: 'Enable OLED Mode',
67+
name: getString.oledThemeVariant,
68+
description: getString.oledThemeVariantDescription,
6969
icon: Icons.brightness_4,
7070
isChecked: themeNotifier.isOled,
7171
onSwitchChange: (bool value) async {
@@ -74,8 +74,8 @@ class SettingsThemeScreenState extends BaseSettingsScreen {
7474
),
7575
Setting(
7676
type: SettingType.switchType,
77-
name: 'Material You',
78-
description: 'Use the same color as your wallpaper',
77+
name: getString.materialYou,
78+
description: getString.materialYouDescription,
7979
icon: Icons.new_releases,
8080
//isVisible: Platform.isAndroid,
8181
isChecked: themeNotifier.useMaterialYou,
@@ -85,8 +85,8 @@ class SettingsThemeScreenState extends BaseSettingsScreen {
8585
),
8686
Setting(
8787
type: SettingType.switchType,
88-
name: 'Custom theme',
89-
description: 'Use your own color for the theme',
88+
name: getString.customTheme,
89+
description: getString.customThemeDescription,
9090
icon: Icons.color_lens_outlined,
9191
isChecked: themeNotifier.useCustomColor,
9292
onSwitchChange: (bool value) async {
@@ -95,8 +95,8 @@ class SettingsThemeScreenState extends BaseSettingsScreen {
9595
),
9696
Setting(
9797
type: SettingType.normal,
98-
name: 'Color Picker',
99-
description: 'Choose a color',
98+
name: getString.colorPicker,
99+
description: getString.colorPickerDescription,
100100
icon: Icons.color_lens_outlined,
101101
onClick: () async {
102102
var color = themeNotifier.customColor;
@@ -108,8 +108,8 @@ class SettingsThemeScreenState extends BaseSettingsScreen {
108108
),
109109
Setting(
110110
type: SettingType.normal,
111-
name: 'Manage Layouts on Anime Page',
112-
description: 'Does not belong here',
111+
name: getString.manageAnimeLayouts,
112+
description: getString.manageAnimeLayoutsDescription,
113113
icon: Icons.palette,
114114
onClick: () async {
115115
final homeLayoutMap = PrefManager.getVal(PrefName.anilistAnimeLayout);
@@ -118,26 +118,26 @@ class SettingsThemeScreenState extends BaseSettingsScreen {
118118
List<bool>.from(homeLayoutMap.values.toList());
119119

120120
AlertDialogBuilder(context)
121-
..setTitle('Manage Layouts on Anime Page')
121+
..setTitle(getString.manageAnimeLayouts)
122122
..reorderableMultiSelectableItems(
123123
titles,
124124
checkedStates,
125125
(reorderedItems) => titles = reorderedItems,
126126
(newCheckedStates) => checkedStates = newCheckedStates,
127127
)
128-
..setPositiveButton('OK', () {
128+
..setPositiveButton(getString.ok, () {
129129
PrefManager.setVal(PrefName.anilistAnimeLayout,
130130
Map.fromIterables(titles, checkedStates));
131131
Refresh.activity[2]?.value = true;
132132
})
133-
..setNegativeButton("Cancel", null)
133+
..setNegativeButton(getString.cancel, null)
134134
..show();
135135
},
136136
),
137137
Setting(
138138
type: SettingType.normal,
139-
name: 'Manage Layouts on Manga Page',
140-
description: 'Does not belong here',
139+
name: getString.manageMangaLayouts,
140+
description: getString.manageMangaLayoutsDescription,
141141
icon: Icons.palette,
142142
onClick: () async {
143143
final homeLayoutMap = PrefManager.getVal(PrefName.anilistMangaLayout);
@@ -146,26 +146,26 @@ class SettingsThemeScreenState extends BaseSettingsScreen {
146146
List<bool>.from(homeLayoutMap.values.toList());
147147

148148
AlertDialogBuilder(context)
149-
..setTitle('Manage Layouts on Manga Page')
149+
..setTitle(getString.manageMangaLayouts)
150150
..reorderableMultiSelectableItems(
151151
titles,
152152
checkedStates,
153153
(reorderedItems) => titles = reorderedItems,
154154
(newCheckedStates) => checkedStates = newCheckedStates,
155155
)
156-
..setPositiveButton('OK', () {
156+
..setPositiveButton(getString.ok, () {
157157
PrefManager.setVal(PrefName.anilistMangaLayout,
158158
Map.fromIterables(titles, checkedStates));
159159
Refresh.activity[3]?.value = true;
160160
})
161-
..setNegativeButton("Cancel", null)
161+
..setNegativeButton(getString.cancel, null)
162162
..show();
163163
},
164164
),
165165
Setting(
166166
type: SettingType.normal,
167-
name: 'Manage Layouts on Home Page',
168-
description: 'Does not belong here',
167+
name: getString.manageHomeLayouts,
168+
description: getString.manageHomeLayoutsDescription,
169169
icon: Icons.palette,
170170
onClick: () async {
171171
final homeLayoutMap = PrefManager.getVal(PrefName.anilistHomeLayout);
@@ -174,19 +174,19 @@ class SettingsThemeScreenState extends BaseSettingsScreen {
174174
List<bool>.from(homeLayoutMap.values.toList());
175175

176176
AlertDialogBuilder(context)
177-
..setTitle('Manage Layouts on Home Page')
177+
..setTitle(getString.manageHomeLayouts)
178178
..reorderableMultiSelectableItems(
179179
titles,
180180
checkedStates,
181181
(reorderedItems) => titles = reorderedItems,
182182
(newCheckedStates) => checkedStates = newCheckedStates,
183183
)
184-
..setPositiveButton('OK', () {
184+
..setPositiveButton(getString.ok, () {
185185
PrefManager.setVal(PrefName.anilistHomeLayout,
186186
Map.fromIterables(titles, checkedStates));
187187
Refresh.activity[1]?.value = true;
188188
})
189-
..setNegativeButton("Cancel", null)
189+
..setNegativeButton(getString.cancel, null)
190190
..show();
191191
},
192192
),

0 commit comments

Comments
 (0)