Skip to content

Commit 5b5f7dc

Browse files
committed
i18n
1 parent 82c2fe2 commit 5b5f7dc

31 files changed

+2977
-588
lines changed

l10n.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
arb-dir: lib/l10n
2-
template-arb-file: intl_en.arb
3-
output-localization-file: openiothub_common_localizations.dart
42
output-class: OpenIoTHubCommonLocalizations
5-
use-deferred-loading: true
6-
nullable-getter: false
7-
3+
output-localization-file: openiothub_common_localizations.dart
84
output-dir: lib/l10n/generated
9-
preferred-supported-locales: ["zh"]
5+
template-arb-file: intl_en.arb
6+
preferred-supported-locales: ["en"]
107
synthetic-package: false
8+
nullable-getter: false
119
format: true
1210
untranslated-messages-file: lib/l10n/untranslated.json

lib/commPages/appInfo.dart

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import 'package:tdesign_flutter/tdesign_flutter.dart';
99
// import 'package:tencent_kit/tencent_kit.dart';
1010
import 'package:wechat_kit/wechat_kit.dart';
1111

12+
import 'package:openiothub_common_pages/openiothub_common_pages.dart';
13+
1214
class AppInfoPage extends StatefulWidget {
1315
AppInfoPage({required Key key}) : super(key: key);
1416

@@ -32,16 +34,18 @@ class _AppInfoPageState extends State<AppInfoPage> {
3234
// 微信分享
3335
late final StreamSubscription<WechatResp> _share;
3436

37+
String share_success = "share success";
38+
String share_failed = "share failed";
3539
// QQ分享
3640
// late final StreamSubscription<TencentResp> _respSubs;
3741
// TencentLoginResp? _loginResp;
3842

3943
void _listenShareMsg(WechatResp resp) {
4044
// final String content = 'share: ${resp.errorCode} ${resp.errorMsg}';
4145
if (resp.errorCode == 0) {
42-
showToast("分享成功!");
46+
showToast(share_success);
4347
} else {
44-
showToast("分享失败!");
48+
showToast(share_failed);
4549
}
4650
}
4751

@@ -79,11 +83,11 @@ class _AppInfoPageState extends State<AppInfoPage> {
7983
@override
8084
Widget build(BuildContext context) {
8185
final List _result = [];
82-
_result.add("App名称:$appName");
83-
_result.add("包名:$packageName");
84-
_result.add("版本:$version");
85-
_result.add("版本号:$buildNumber");
86-
_result.add("APP备案号:皖ICP备2022013511号-2A");
86+
_result.add("${OpenIoTHubCommonLocalizations.of(context).app_name}$appName");
87+
_result.add("${OpenIoTHubCommonLocalizations.of(context).package_name}$packageName");
88+
_result.add("${OpenIoTHubCommonLocalizations.of(context).version}$version");
89+
_result.add("${OpenIoTHubCommonLocalizations.of(context).version_sn}$buildNumber");
90+
_result.add("${OpenIoTHubCommonLocalizations.of(context).icp_number}皖ICP备2022013511号-2A");
8791

8892
final tiles = _result.map(
8993
(pair) {
@@ -97,7 +101,7 @@ class _AppInfoPageState extends State<AppInfoPage> {
97101
List<ListTile> tilesList = tiles.toList();
98102
tilesList.add(ListTile(
99103
title: Text(
100-
"反馈渠道",
104+
OpenIoTHubCommonLocalizations.of(context).feedback_channels,
101105
style: TextStyle(color: Colors.green),
102106
),
103107
onTap: () {
@@ -111,7 +115,7 @@ class _AppInfoPageState extends State<AppInfoPage> {
111115
));
112116
tilesList.add(ListTile(
113117
title: Text(
114-
"在线反馈",
118+
OpenIoTHubCommonLocalizations.of(context).online_feedback,
115119
style: TextStyle(color: Colors.green),
116120
),
117121
onTap: () {
@@ -120,12 +124,12 @@ class _AppInfoPageState extends State<AppInfoPage> {
120124
));
121125
tilesList.add(ListTile(
122126
title: Text(
123-
"隐私政策",
127+
OpenIoTHubCommonLocalizations.of(context).privacy_policy,
124128
style: TextStyle(color: Colors.green),
125129
),
126130
onTap: () {
127131
goToURL(context, "https://docs.iothub.cloud/privacyPolicy/index.html",
128-
"隐私政策");
132+
OpenIoTHubCommonLocalizations.of(context).privacy_policy);
129133
},
130134
));
131135
final divided = ListTile.divideTiles(
@@ -134,7 +138,7 @@ class _AppInfoPageState extends State<AppInfoPage> {
134138
).toList();
135139

136140
return Scaffold(
137-
appBar: AppBar(title: Text("App信息"), actions: <Widget>[
141+
appBar: AppBar(title: Text(OpenIoTHubCommonLocalizations.of(context).app_info), actions: <Widget>[
138142
IconButton(
139143
icon: Icon(
140144
Icons.share,
@@ -160,27 +164,27 @@ class _AppInfoPageState extends State<AppInfoPage> {
160164
}
161165

162166
_shareAction() async {
163-
var title = "云亿连内网穿透和智能家居管理";
164-
var description = "云亿连全平台管理您的所有智能设备和私有云";
167+
var title = OpenIoTHubCommonLocalizations.of(context).share_app_title;
168+
var description = OpenIoTHubCommonLocalizations.of(context).share_app_description;
165169
var url = "https://m.malink.cn/s/RNzqia";
166170
showDialog(
167171
context: context,
168172
builder: (_) => AlertDialog(
169-
title: Text("分享"),
170-
content: Text("选择需方分享的位置"),
173+
title: Text(OpenIoTHubCommonLocalizations.of(context).share),
174+
content: Text(OpenIoTHubCommonLocalizations.of(context).share_to_where),
171175
actions: <Widget>[
172176
Row(
173177
children: [
174178
TDButton(
175179
icon: TDIcons.logo_wechat_stroke,
176-
text: '分享到微信',
180+
text: OpenIoTHubCommonLocalizations.of(context).share_to_wechat,
177181
size: TDButtonSize.small,
178182
type: TDButtonType.outline,
179183
shape: TDButtonShape.rectangle,
180184
theme: TDButtonTheme.primary,
181185
onTap: () async {
182186
if (!await WechatKitPlatform.instance.isInstalled()) {
183-
showToast("微信未安装!");
187+
showToast(OpenIoTHubCommonLocalizations.of(context).wechat_not_installed);
184188
return;
185189
}
186190
WechatKitPlatform.instance.shareWebpage(
@@ -197,15 +201,15 @@ class _AppInfoPageState extends State<AppInfoPage> {
197201
padding: const EdgeInsets.only(left: 10.0), // 设置左边距离
198202
child: TDButton(
199203
icon: TDIcons.logo_wechat_stroke,
200-
text: '分享到朋友圈',
204+
text: OpenIoTHubCommonLocalizations.of(context).share_on_moments,
201205
size: TDButtonSize.small,
202206
type: TDButtonType.outline,
203207
shape: TDButtonShape.rectangle,
204208
theme: TDButtonTheme.primary,
205209
onTap: () async {
206210
if (!await WechatKitPlatform.instance
207211
.isInstalled()) {
208-
showToast("微信未安装!");
212+
showToast(OpenIoTHubCommonLocalizations.of(context).wechat_not_installed);
209213
return;
210214
}
211215
WechatKitPlatform.instance.shareWebpage(

lib/commPages/feedback.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
22

33
class FeedbackPage extends StatelessWidget {
44
const FeedbackPage({required Key key}) : super(key: key);
5-
5+
// TODO 没有翻译国际化
66
@override
77
Widget build(BuildContext context) {
88
final List _result = [];

lib/commPages/findmDNSClientList.dart

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import 'package:openiothub_grpc_api/proto/mobile/mobile.pb.dart';
1414
import 'package:openiothub_grpc_api/proto/mobile/mobile.pbgrpc.dart';
1515
import 'package:openiothub_plugin/plugins/mdnsService/components.dart';
1616

17+
import 'package:openiothub_common_pages/openiothub_common_pages.dart';
18+
1719
const utf8encoder = Utf8Encoder();
1820

1921
class FindmDNSClientListPage extends StatefulWidget {
@@ -150,7 +152,7 @@ class _FindmDNSClientListPageState extends State<FindmDNSClientListPage> {
150152
).toList();
151153
return Scaffold(
152154
appBar: AppBar(
153-
title: Text("发现本地网关列表"),
155+
title: Text(OpenIoTHubCommonLocalizations.of(context).find_local_gateway_list),
154156
actions: <Widget>[
155157
// IconButton(
156158
// icon: Icon(
@@ -198,17 +200,17 @@ class _FindmDNSClientListPageState extends State<FindmDNSClientListPage> {
198200
builder: (context) {
199201
return StatefulBuilder(builder: (context, state) {
200202
return AlertDialog(
201-
title: Text("手动创建一个网关?"),
203+
title: Text(OpenIoTHubCommonLocalizations.of(context).manually_create_a_gateway),
202204
content: SizedBox.expand(
203205
child: ListView(
204206
children: ListTile.divideTiles(
205207
context: context,
206208
tiles: [
207-
Text("安装的网关可以本页面发现"),
209+
Text(OpenIoTHubCommonLocalizations.of(context).manually_create_a_gateway_description1),
208210
Text(
209-
"自动生成一个网关信息,回头拿着token填写到网关配置文件即可,适合于手机无法同局域网发现网关的情况"),
211+
OpenIoTHubCommonLocalizations.of(context).manually_create_a_gateway_description2),
210212
Text(
211-
"从下面选择网关需要连接的服务器:",
213+
OpenIoTHubCommonLocalizations.of(context).manually_create_a_gateway_description3,
212214
style: TextStyle(
213215
color: Colors.amber,
214216
),
@@ -227,13 +229,13 @@ class _FindmDNSClientListPageState extends State<FindmDNSClientListPage> {
227229
)),
228230
actions: <Widget>[
229231
TextButton(
230-
child: Text("取消"),
232+
child: Text(OpenIoTHubCommonLocalizations.of(context).cancel),
231233
onPressed: () {
232234
Navigator.of(context).pop();
233235
},
234236
),
235237
TextButton(
236-
child: Text("添加"),
238+
child: Text(OpenIoTHubCommonLocalizations.of(context).add),
237239
onPressed: () async {
238240
// 从服务器自动生成一个网关
239241
// TODO 选择服务器
@@ -253,7 +255,7 @@ loginwithtokenmap:
253255
$uuid: $gatewayJwt
254256
''';
255257
Clipboard.setData(ClipboardData(text: data));
256-
showToast("网关的id与token已经复制到剪切板,请将剪切板的配置填写到网关的配置文件中");
258+
showToast(OpenIoTHubCommonLocalizations.of(context).paste_info);
257259
Navigator.of(context).pop();
258260
},
259261
)
@@ -269,9 +271,9 @@ loginwithtokenmap:
269271
config.description = description;
270272
try {
271273
await SessionApi.createOneSession(config);
272-
showToast("添加网关成功!");
274+
showToast(OpenIoTHubCommonLocalizations.of(context).add_gateway_success);
273275
} catch (exception) {
274-
showToast("登录失败:${exception}");
276+
showToast("${OpenIoTHubCommonLocalizations.of(context).login_failed}:${exception}");
275277
}
276278
}
277279

lib/commPages/gatewayGuide.dart

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:url_launcher/url_launcher.dart';
3+
import 'package:url_launcher/url_launcher_string.dart';
4+
import 'package:openiothub_common_pages/openiothub_common_pages.dart';
35

46
class GatewayGuidePage extends StatefulWidget {
57
const GatewayGuidePage({required Key key}) : super(key: key);
@@ -13,39 +15,39 @@ class _GatewayGuidePageState extends State<GatewayGuidePage> {
1315
Widget build(BuildContext context) {
1416
return Scaffold(
1517
appBar: AppBar(
16-
title: Text("网关安装指南"),
18+
title: Text(OpenIoTHubCommonLocalizations.of(context).gateway_install_guide),
1719
actions: <Widget>[],
1820
),
1921
body: ListView(
2022
children: [
2123
Text(
22-
"这里介绍怎样安装一个自己的网关",
24+
OpenIoTHubCommonLocalizations.of(context).gateway_install_guide_content1,
2325
style: TextStyle(fontSize: 23),
2426
),
25-
Text("首先,你需要将网关安装到你需要访问的局域网持续运行"),
26-
Text("第一次的时候,将本APP也接入网关所在的局域网"),
27-
Text("APP在局域网搜索并配置添加网关一次后"),
28-
Text("以后只要网关在线手机客户端都可以访问"),
27+
Text(OpenIoTHubCommonLocalizations.of(context).gateway_install_guide_content2),
28+
Text(OpenIoTHubCommonLocalizations.of(context).gateway_install_guide_content3),
29+
Text(OpenIoTHubCommonLocalizations.of(context).gateway_install_guide_content4),
30+
Text(OpenIoTHubCommonLocalizations.of(context).gateway_install_guide_content5),
2931
Text(
30-
"这里介绍如何在你所需要访问的网络安装网关",
32+
OpenIoTHubCommonLocalizations.of(context).gateway_install_guide_content6,
3133
style: TextStyle(fontSize: 23),
3234
),
3335
TextButton(
3436
onPressed: () {
3537
_launchURL("https://github.com/OpenIoTHub/gateway-go/releases");
3638
},
37-
child: Text("查看网关的开源地址")),
38-
Text("openwrt路由器snapshot源安装:opkg install gateway-go"),
39-
Text("MacOS使用homebrew安装:brew install gateway-go"),
40-
Text("Linux使用snapcraft安装:sudo snap install gateway-go"),
39+
child: Text(OpenIoTHubCommonLocalizations.of(context).gateway_install_guide_content7)),
40+
Text(OpenIoTHubCommonLocalizations.of(context).gateway_install_guide_content8),
41+
Text(OpenIoTHubCommonLocalizations.of(context).gateway_install_guide_content9),
42+
Text(OpenIoTHubCommonLocalizations.of(context).gateway_install_guide_content10),
4143
],
4244
),
4345
);
4446
}
4547

4648
_launchURL(String url) async {
47-
if (await canLaunch(url)) {
48-
await launch(url);
49+
if (await canLaunchUrlString(url)) {
50+
await launchUrlString(url);
4951
} else {
5052
print('Could not launch $url');
5153
}

lib/commPages/privacyPolicy.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
33
class PrivacyPolicyPage extends StatelessWidget {
44
const PrivacyPolicyPage({required Key key}) : super(key: key);
55

6+
// TODO 国际化
7+
68
@override
79
Widget build(BuildContext context) {
810
return Scaffold(

0 commit comments

Comments
 (0)