Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix locale in get-cli standard #81

Merged
merged 9 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ start the front-end flutter project in `debug` mode to run.
The internationalization files of Gopeed are located in the `ui/flutter/assets/locales` directory.
You only need to add the corresponding language file in this directory.

Generate locales after you edit locales/internationalization:

Generate locales after you edit locales:


```
get generate locales
Expand Down
8 changes: 6 additions & 2 deletions CONTRIBUTING_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ flutter 项目即可运行。

Gopeed 的国际化文件位于 `ui/flutter/assets/locales` 目录下,只需要在该目录下添加对应的语言文件即可。

编辑locales/internationalization后请运行以下命令:

编辑locales后请运行以下命令:


```
get generate locales
```

请注意以 `en_US.json` 为参照进行翻译。

## flutter development

## flutter开发


每次提交前请务必运行`dart format .`

Expand Down
3 changes: 2 additions & 1 deletion ui/flutter/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
.packages
.pub-cache/
.pub/
/build/
build/
.fvm/

# Web related

Expand Down
2 changes: 1 addition & 1 deletion ui/flutter/assets/locales/fa_IR.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"downloading": "downloading",
"downloaded": "downloaded",
"setting": "تنظیمات",
"title": "ایجاد کار",
"create": "ایجاد کار",
"downloadLink": "لینک دانلود",
"downloadLinkValid": "لطفا لینک دانلود را وارد کنید",
"downloadLinkHit": "Please enter the download link, HTTP/HTTPS/MAGNET supported@append",
Expand Down
2 changes: 1 addition & 1 deletion ui/flutter/assets/locales/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"downloading": "downloading",
"downloaded": "downloaded",
"setting": "Настройки",
"title": "Создать задачу",
"create": "Создать задачу",
"downloadLink": "Ссылка для скачивание",
"downloadLinkValid": "Пожалуйста, введите ссылку для скачивания",
"downloadLinkHit": "Пожалуйста, введите ссылку для скачивания, HTTP/HTTPS/MAGNET supported@append",
Expand Down
2 changes: 1 addition & 1 deletion ui/flutter/assets/locales/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"downloading": "下载中",
"downloaded": "已完成",
"setting": "设置",
"title": "创建任务",
"create": "创建任务",
"downloadLink": "下载链接",
"downloadLinkValid": "请输入下载链接",
"downloadLinkHit": "请输入下载链接,支持 HTTP/HTTPS/MAGNET@append",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import '../../../../api/api.dart';
import '../../../../api/model/downloader_config.dart';
import '../../../../core/common/start_config.dart';
import '../../../../generated/locales.g.dart';
import '../../../../i18n/messages.dart';
import '../../../../util/log_util.dart';
import '../../../../util/util.dart';
Expand Down Expand Up @@ -184,7 +185,7 @@ class AppController extends GetxController {
}
if (extra.locale.isEmpty) {
final systemLocale = getLocaleKey(ui.window.locale);
extra.locale = messages.keys.containsKey(systemLocale)
extra.locale = AppTranslation.translations.containsKey(systemLocale)
? systemLocale
: getLocaleKey(fallbackLocale);
}
Expand Down
3 changes: 2 additions & 1 deletion ui/flutter/lib/app/modules/app/views/app_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class AppView extends GetView<AppController> {
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: messages.keys.keys.map((e) => toLocale(e)).toList(),
supportedLocales:
AppTranslation.translations.keys.map((e) => toLocale(e)).toList(),
getPages: AppPages.routes,
);
}
Expand Down
14 changes: 7 additions & 7 deletions ui/flutter/lib/app/modules/create/views/create_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CreateView extends GetView<CreateController> {
icon: const Icon(Icons.arrow_back),
onPressed: () => Get.rootDelegate.offNamed(Routes.DOWNLOADING)),
// actions: [],
title: Text('create.title'.tr),
title: Text('create'.tr),
),
body: DropTarget(
onDragDone: (details) {
Expand All @@ -52,12 +52,12 @@ class CreateView extends GetView<CreateController> {
decoration: InputDecoration(
hintText: _hitText(),
hintStyle: const TextStyle(fontSize: 12),
labelText: 'create.downloadLink'.tr,
labelText: 'downloadLink'.tr,
icon: const Icon(Icons.link)),
validator: (v) {
return v!.trim().isNotEmpty
? null
: 'create.downloadLinkValid'.tr;
: 'downloadLinkValid'.tr;
}),
Center(
child: Padding(
Expand Down Expand Up @@ -98,8 +98,8 @@ class CreateView extends GetView<CreateController> {
}

String _hitText() {
return 'create.downloadLinkHit'.trParams({
'append': Util.isDesktop() ? 'create.downloadLinkHitDesktop'.tr : '',
return 'downloadLinkHit'.trParams({
'append': Util.isDesktop() ? 'downloadLinkHitDesktop'.tr : '',
});
}

Expand Down Expand Up @@ -172,7 +172,7 @@ class CreateView extends GetView<CreateController> {
// if (Util.isAndroid()) {
// if (!await Permission.storage.request().isGranted) {
// Get.snackbar('error'.tr,
// 'create.error.noStoragePermission'.tr);
// 'noStoragePermission'.tr);
// return;
// }
// }
Expand All @@ -195,7 +195,7 @@ class CreateView extends GetView<CreateController> {
}
},
controller: downloadController,
child: Text('create.download'.tr),
child: Text('download'.tr),
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion ui/flutter/lib/app/modules/home/views/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class HomeView extends GetView<HomeController> {
? NavigationRail(
extended: true,
labelType: NavigationRailLabelType.none,
minExtendedWidth: 140,
minExtendedWidth: 170,
groupAlignment: 0,
// useIndicator: false,
onDestinationSelected: (int index) {
Expand Down
8 changes: 5 additions & 3 deletions ui/flutter/lib/app/modules/setting/views/setting_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:url_launcher/url_launcher.dart';

import '../../../../generated/locales.g.dart';
import '../../../../i18n/messages.dart';
import '../../../../util/package_info.dart';
import '../../../../util/util.dart';
Expand Down Expand Up @@ -202,7 +203,8 @@ class SettingView extends GetView<SettingController> {
));
final buildLocale = _buildConfigItem(
'locale',
() => messages.keys[downloaderCfg.value.extra.locale]!['label']!,
() => AppTranslation
.translations[downloaderCfg.value.extra.locale]!['label']!,
(Key key) => DropdownButton<String>(
key: key,
value: downloaderCfg.value.extra.locale,
Expand All @@ -216,10 +218,10 @@ class SettingView extends GetView<SettingController> {

await debounceSave();
},
items: messages.keys.keys
items: AppTranslation.translations.keys
.map((e) => DropdownMenuItem<String>(
value: e,
child: Text(messages.keys[e]!['label']!),
child: Text(AppTranslation.translations[e]!['label']!),
))
.toList(),
));
Expand Down
6 changes: 3 additions & 3 deletions ui/flutter/lib/app/views/views/buid_task_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ class BuildTaskListView extends GetView {
actions: <Widget>[
IconButton(
icon: const Icon(Icons.add),
tooltip: 'create.title'.tr,
tooltip: 'create'.tr,
onPressed: () {
Get.rootDelegate.toNamed(Routes.CREATE);
},
),
//TODO appBar toggleALl/start selected/delete selected/
// IconButton(
// icon: const Icon(Icons.pause),
// tooltip: 'create.title'.tr,
// tooltip: 'title'.tr,
// onPressed: () {
// // pause all
// },
// ),
// IconButton(
// icon: const Icon(Icons.delete),
// tooltip: 'create.title'.tr,
// tooltip: 'title'.tr,
// onPressed: () {
// // delete all
// },
Expand Down
2 changes: 1 addition & 1 deletion ui/flutter/lib/app/views/views/file_list_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class FileListView extends GetView {
children: [
const Padding(padding: EdgeInsets.only(top: 10)),
Text(
'create.selectFile'.tr,
'selectFile'.tr,
// style: TextStyle(color: themeData.hintColor),
),
Expanded(
Expand Down
58 changes: 0 additions & 58 deletions ui/flutter/lib/i18n/langs/en_us.dart

This file was deleted.

58 changes: 0 additions & 58 deletions ui/flutter/lib/i18n/langs/fa_ir.dart

This file was deleted.

Loading