Skip to content

Commit

Permalink
Supported to change language in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
shoothzj committed Jul 31, 2021
1 parent ee45615 commit 37bbb9b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/ui/bk/bk_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';
import 'package:paas_dashboard_flutter/ui/util/form_util.dart';
import 'package:paas_dashboard_flutter/vm/bk/bk_instance_list_view_model.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -28,7 +29,7 @@ class _BkPageState extends State<BkPage> {
vm.fetchBkInstances();
});
},
child: Text('Refresh'));
child: Text(S.of(context).refresh));
var body = ListView(
children: [
Container(
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/pulsar/screen/pulsar_namespace.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';
import 'package:paas_dashboard_flutter/module/pulsar/pulsar_topic.dart';
import 'package:paas_dashboard_flutter/route/page_route_const.dart';
import 'package:paas_dashboard_flutter/ui/util/alert_util.dart';
Expand Down Expand Up @@ -94,7 +95,7 @@ class PulsarNamespaceScreenState extends State<PulsarNamespaceScreen> {
onPressed: () {
vm.fetchTopics();
},
child: Text('Refresh'));
child: Text(S.of(context).refresh));
var searchBox = Container(
width: 300,
child: TextField(
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/pulsar/screen/pulsar_tenant.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';
import 'package:paas_dashboard_flutter/route/page_route_const.dart';
import 'package:paas_dashboard_flutter/ui/pulsar/pulsar_const.dart';
import 'package:paas_dashboard_flutter/ui/util/alert_util.dart';
Expand Down Expand Up @@ -60,7 +61,7 @@ class PulsarTenantScreenState extends State<PulsarTenantScreen> {
onPressed: () {
vm.fetchNamespaces();
},
child: Text('Refresh'));
child: Text(S.of(context).refresh));
var searchBox = Container(
width: 300,
child: TextField(
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/pulsar/tab/pulsar_details.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';
import 'package:paas_dashboard_flutter/route/page_route_const.dart';
import 'package:paas_dashboard_flutter/ui/util/alert_util.dart';
import 'package:paas_dashboard_flutter/ui/util/form_util.dart';
Expand Down Expand Up @@ -59,7 +60,7 @@ class PulsarTenantsState extends State<PulsarTenantsWidget> {
onPressed: () {
vm.fetchTenants();
},
child: Text('Refresh'));
child: Text(S.of(context).refresh));
var searchBox = Container(
width: 300,
child: TextField(
Expand Down
20 changes: 19 additions & 1 deletion lib/vm/general/settings_view_model.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:paas_dashboard_flutter/generated/l10n.dart';

class SettingsViewModel extends ChangeNotifier {
String language = 'en';
String language = "zh";

SettingsViewModel() {
if (!kIsWeb) {
this.language = Platform.localeName.split("_")[0];
}
}

void setLan(String lan) {
this.language = lan;
switch (lan) {
case "zh":
S.load(Locale('zh', 'CN'));
break;
case "en":
S.load(Locale('en', 'US'));
break;
}
notifyListeners();
}
}

0 comments on commit 37bbb9b

Please sign in to comment.