QuizApp
使用Flutter和Firebase构建的QuizApp
由 Very Good CLI 生成?
入门?
该项目包含2个风味
- 开发
- 生产
要运行所需的风味,可以使用 VSCode/Android Studio 中的启动配置,或使用以下命令
# Development
$ flutter run --flavor development --target lib/main_development.dart
# Production
$ flutter run --flavor production --target lib/main_production.dart
*Quizapp 支持 iOS 和 Android。
正在运行测试?
要运行所有单元和 widget 测试,请使用以下命令
$ flutter test --test-randomize-ordering-seed random
正在处理翻译?
该项目依赖于 flutter_localizations 并遵循 Flutter 的 官方国际化指南。
添加字符串
- 要添加新的本地化字符串,请打开位于
lib/l10n/arb/app_en.arb的app_en.arb文件。
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
}
}
- 然后添加新的键/值和描述
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
},
"helloWorld": "Hello World",
"@helloWorld": {
"description": "Hello World Text"
}
}
- 使用新字符串
import 'package:quizapp/l10n/l10n.dart';
@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return Text(l10n.helloWorld);
}
添加支持的区域设置
更新位于 ios/Runner/Info.plist 的 Info.plist 中的 CFBundleLocalizations 数组,以包含新的区域设置。
...
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>es</string>
</array>
...
添加翻译
- 对于每个支持的区域设置,请在
lib/l10n/arb中添加一个新的 ARB 文件。
├── l10n
│ ├── arb
│ │ ├── app_en.arb
│ │ └── app_es.arb
- 将翻译后的字符串添加到每个
.arb文件中
app_en.arb
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
}
}
app_es.arb
{
"@@locale": "es",
"counterAppBarTitle": "Contador",
"@counterAppBarTitle": {
"description": "Texto mostrado en la AppBar de la página del contador"
}
}