Skip to content

Commit cd73101

Browse files
authored
Merge pull request #31 from attme0/language_menu
Added language change option in settings
2 parents 401006d + 2a4cb46 commit cd73101

File tree

6 files changed

+67
-1
lines changed

6 files changed

+67
-1
lines changed

lib/l10n/generated/localizations.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,18 @@ abstract class ReviLocalizations {
612612
/// In en, this message translates to:
613613
/// **''**
614614
String get settingsEPTDescription;
615+
616+
///
617+
///
618+
/// In en, this message translates to:
619+
/// **'You must restart your app for the changes to take effect'**
620+
String get restartAppDialog;
621+
622+
///
623+
///
624+
/// In en, this message translates to:
625+
/// **'Language'**
626+
String get settingsLanguageLabel;
615627
}
616628

617629
class _ReviLocalizationsDelegate extends LocalizationsDelegate<ReviLocalizations> {

lib/l10n/generated/localizations_en.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,10 @@ class ReviLocalizationsEn extends ReviLocalizations {
264264

265265
@override
266266
String get settingsEPTDescription => '';
267+
268+
@override
269+
String get restartAppDialog => 'You must restart your app for the changes to take effect';
270+
271+
@override
272+
String get settingsLanguageLabel => 'Language';
267273
}

lib/l10n/intl_en.arb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,5 +353,13 @@
353353
"settingsEPTDescription": "",
354354
"@settingsEPTDescription": {
355355
"description": "The description for Show experimental tweaks"
356+
},
357+
"restartAppDialog": "You must restart your app for the changes to take effect",
358+
"@restartAppDialog": {
359+
"description": ""
360+
},
361+
"settingsLanguageLabel": "Language",
362+
"@settingsLanguageLabel": {
363+
"description": ""
356364
}
357365
}

lib/main.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ void main() async {
2020
r'SOFTWARE\Revision\Revision Tool', 'ThemeMode', ThemeMode.system.name);
2121
writeRegistryDword(Registry.localMachine,
2222
r'SOFTWARE\Revision\Revision Tool', 'Experimental', 0);
23+
writeRegistryString(Registry.localMachine,
24+
r'SOFTWARE\Revision\Revision Tool', 'Language', 'en_US');
2325
}
2426
final settingsController = AppTheme(SettingsService());
2527
await settingsController.loadSettings();
@@ -53,6 +55,7 @@ class MyApp extends StatelessWidget {
5355

5456
@override
5557
Widget build(BuildContext context) {
58+
5659
return ChangeNotifierProvider(
5760
create: (_) => AppTheme(SettingsService()),
5861
builder: (context, _) {
@@ -65,7 +68,7 @@ class MyApp extends StatelessWidget {
6568
ReviLocalizations.delegate,
6669
GlobalWidgetsLocalizations.delegate,
6770
],
68-
locale: appTheme.locale,
71+
locale: Locale(appLanguage.split('_')[0], appLanguage.split('_')[1]),
6972
supportedLocales: ReviLocalizations.supportedLocales,
7073
themeMode: appTheme.themeMode,
7174
color: appTheme.color,

lib/screens/settings.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,40 @@ class _SettingsPageState extends State<SettingsPage> {
136136
},
137137
),
138138
),
139+
CardHighlight(
140+
icon: msicons.FluentIcons.local_language_20_regular,
141+
label: ReviLocalizations.of(context).settingsLanguageLabel,
142+
child: ComboBox(
143+
value: appLanguage,
144+
onChanged: (value) {
145+
setState(() {
146+
appLanguage = value ?? 'en_US';
147+
writeRegistryString(Registry.localMachine,
148+
r'SOFTWARE\Revision\Revision Tool', 'Language', appLanguage);
149+
});
150+
showDialog(
151+
context: context,
152+
builder: (context) => ContentDialog(
153+
content: Text(ReviLocalizations.of(context).restartAppDialog),
154+
actions: [
155+
Button(
156+
child: Text(ReviLocalizations.of(context).okButton),
157+
onPressed: () {
158+
Navigator.pop(context);
159+
},
160+
)
161+
],
162+
),
163+
);
164+
},
165+
items: [
166+
ComboBoxItem(
167+
value: 'en_US',
168+
child: Text('English'),
169+
)
170+
],
171+
),
172+
),
139173
],
140174
);
141175
}

lib/utils.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ bool expBool = readRegistryInt(RegistryHive.localMachine,
2424
String? themeModeReg = readRegistryString(
2525
RegistryHive.localMachine, r'SOFTWARE\Revision\Revision Tool', 'ThemeMode');
2626

27+
String appLanguage = readRegistryString(
28+
RegistryHive.localMachine, r'SOFTWARE\Revision\Revision Tool', 'Language',) ?? 'en_US';
29+
2730
int? readRegistryInt(RegistryHive hive, String path, String value) {
2831
try {
2932
return Registry.openPath(

0 commit comments

Comments
 (0)