l10n support

hmxc
小赖 4 years ago
parent 08f86b30ae
commit 49991ff863

1
.gitattributes vendored

@ -0,0 +1 @@
*.arb diff

@ -0,0 +1,4 @@
arb-dir: lib/l10n
template-arb-file: app_zh.arb
output-localization-file: app_localizations.dart
output-class: S

@ -1,3 +1,3 @@
class AppValues { // class AppValues {
static const String plotName = '人才公寓智慧小区'; // static const String plotName = '人才公寓智慧小区';
} // }

@ -0,0 +1,10 @@
{
"appName": "智慧社区",
"@appName":{
"description": "应用名称"
},
"tempPlotName": "人才公寓智慧小区",
"@tempPlotName":{
"description": "临时使用的小区名称"
}
}

@ -17,6 +17,7 @@ import 'package:akuCommunity/provider/cart.dart';
import 'package:akuCommunity/provider/sign_up_provider.dart'; import 'package:akuCommunity/provider/sign_up_provider.dart';
import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/provider/user_provider.dart';
import 'package:akuCommunity/utils/developer_util.dart'; import 'package:akuCommunity/utils/developer_util.dart';
import 'package:akuCommunity/utils/headers.dart';
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -87,17 +88,18 @@ class _MyAppState extends State<MyApp> {
designSize: Size(750, 1334), designSize: Size(750, 1334),
allowFontScaling: true, allowFontScaling: true,
builder: () => GetMaterialApp( builder: () => GetMaterialApp(
title: '智慧社区', onGenerateTitle: (context) => S.of(context).appName,
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
theme: AppTheme.theme, theme: AppTheme.theme,
home: SplashPage(), home: SplashPage(),
// //
localizationsDelegates: [ localizationsDelegates: [
S.delegate,
GlobalMaterialLocalizations.delegate, GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate, GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
], ],
supportedLocales: [const Locale('zh', 'CH')], supportedLocales: [const Locale('zh')],
locale: Locale('zh'), locale: Locale('zh'),
builder: BotToastInit(), builder: BotToastInit(),
navigatorObservers: [BotToastNavigatorObserver()], navigatorObservers: [BotToastNavigatorObserver()],

@ -1,13 +1,12 @@
import 'package:akuCommunity/constants/app_values.dart';
import 'package:akuCommunity/provider/app_provider.dart'; import 'package:akuCommunity/provider/app_provider.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_icons/flutter_icons.dart'; import 'package:flutter_icons/flutter_icons.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:qr_flutter/qr_flutter.dart'; import 'package:qr_flutter/qr_flutter.dart';
import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/model/manager/article_QR_code_model.dart'; import 'package:akuCommunity/model/manager/article_QR_code_model.dart';
import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart';
@ -25,7 +24,7 @@ class DetoCodePage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Text( Text(
AppValues.plotName, S.of(Get.context).tempPlotName,
style: TextStyle(fontSize: 40.sp, color: Color(0xffffffff)), style: TextStyle(fontSize: 40.sp, color: Color(0xffffffff)),
), ),
SizedBox(height: 10.w), SizedBox(height: 10.w),

@ -109,7 +109,7 @@ class _DetoCreatePageState extends State<DetoCreatePage> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
AppValues.plotName, S.of(context).tempPlotName,
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
fontSize: 32.sp, fontSize: 32.sp,

@ -1,4 +1,5 @@
import 'package:akuCommunity/constants/app_values.dart'; import 'package:akuCommunity/constants/app_values.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -40,7 +41,7 @@ class _AnimateAppBarState extends State<AnimateAppBar> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final appProvider = Provider.of<AppProvider>(context); final appProvider = Provider.of<AppProvider>(context);
return AppBar( return AppBar(
title: Text(AppValues.plotName), title: Text( S.of(context).tempPlotName),
backgroundColor: _bgColor, backgroundColor: _bgColor,
leading: Container( leading: Container(
margin: EdgeInsets.only(left: 32.w), margin: EdgeInsets.only(left: 32.w),

@ -82,7 +82,14 @@ class _LifePayPageState extends State<LifePayPage> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
AppValues.plotName.text.black.size(32.sp).bold.make(), S
.of(context)
.tempPlotName
.text
.black
.size(32.sp)
.bold
.make(),
10.w.heightBox, 10.w.heightBox,
appProvider.selectedHouse.roomName.text.black appProvider.selectedHouse.roomName.text.black
.size(32.sp) .size(32.sp)

@ -94,7 +94,7 @@ class _LifePayDetailPageState extends State<LifePayDetailPage> {
children: [ children: [
model.name.text.black.size(30.sp).bold.make(), model.name.text.black.size(30.sp).bold.make(),
Spacer(), Spacer(),
'${AppValues.plotName} ${userProvider.currentHouse}' '${S.of(context).tempPlotName} ${userProvider.currentHouse}'
.text .text
.color(ktextSubColor) .color(ktextSubColor)
.size(24.sp) .size(24.sp)

@ -87,7 +87,10 @@ class _MyHousePageState extends State<MyHousePage> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
AppValues.plotName.text S
.of(context)
.tempPlotName
.text
.size(24.sp) .size(24.sp)
.color(ktextSubColor) .color(ktextSubColor)
.bold .bold

@ -4,6 +4,7 @@ import 'package:akuCommunity/constants/app_values.dart';
import 'package:akuCommunity/provider/app_provider.dart'; import 'package:akuCommunity/provider/app_provider.dart';
import 'package:akuCommunity/ui/profile/house/house_owners_page.dart'; import 'package:akuCommunity/ui/profile/house/house_owners_page.dart';
import 'package:akuCommunity/ui/profile/house/pick_my_house_page.dart'; import 'package:akuCommunity/ui/profile/house/pick_my_house_page.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -221,7 +222,7 @@ class _AddFixedSubmitPageState extends State<AddFixedSubmitPage> {
body: ListView( body: ListView(
children: [ children: [
_buildHouseCard( _buildHouseCard(
AppValues.plotName, S.of(context).tempPlotName,
appProvider.selectedHouse.roomName, appProvider.selectedHouse.roomName,
), ),
_getType(), _getType(),

@ -306,7 +306,7 @@ class _VisitorAccessPageState extends State<VisitorAccessPage> {
child: Column( child: Column(
children: [ children: [
_buildHouseCard( _buildHouseCard(
AppValues.plotName, S.of(context).tempPlotName,
appProvider.selectedHouse.roomName, appProvider.selectedHouse.roomName,
), ),
_input('访客姓名', '请输入访客姓名', _userName), _input('访客姓名', '请输入访客姓名', _userName),

@ -145,7 +145,7 @@ class _NewAdvicePageState extends State<NewAdvicePage> {
width: 60.w, width: 60.w,
), ),
40.wb, 40.wb,
'${AppValues.plotName}\n${appProvider.selectedHouse.roomName}' '${S.of(context).tempPlotName}\n${appProvider.selectedHouse.roomName}'
.text .text
.size(32.sp) .size(32.sp)
.black .black

@ -36,7 +36,7 @@ class CarManageCard extends StatelessWidget {
), ),
), ),
Text( Text(
AppValues.plotName, S.of(context).tempPlotName,
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.subtitle2 .subtitle2

@ -36,7 +36,7 @@ class CarparkingCard extends StatelessWidget {
), ),
), ),
Text( Text(
AppValues.plotName, S.of(context).tempPlotName,
style: Theme.of(context) style: Theme.of(context)
.textTheme .textTheme
.subtitle2 .subtitle2

@ -171,7 +171,7 @@ class _AddHousePageState extends State<AddHousePage> {
_renderTile( _renderTile(
title: '小区名称', title: '小区名称',
item: _renderPicker( item: _renderPicker(
text: AppValues.plotName, text: S.of(context).tempPlotName,
hintText: '请选择小区', hintText: '请选择小区',
// //
// TODO // TODO

@ -109,7 +109,7 @@ class HouseCard extends StatelessWidget {
), ),
), ),
onPressed: () { onPressed: () {
Get.to(()=>PickMyHousePage()); Get.to(() => PickMyHousePage());
}, },
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: borderRadius:
@ -119,7 +119,7 @@ class HouseCard extends StatelessWidget {
), ),
12.hb, 12.hb,
Text( Text(
AppValues.plotName, S.of(context).tempPlotName,
style: Theme.of(context).textTheme.headline3, style: Theme.of(context).textTheme.headline3,
), ),
10.hb, 10.hb,

@ -196,7 +196,7 @@ class _HouseCard extends StatelessWidget {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Text( Text(
AppValues.plotName, S.of(context).tempPlotName,
style: Theme.of(context).textTheme.subtitle1.copyWith( style: Theme.of(context).textTheme.subtitle1.copyWith(
color: color:
highlight ? Color(0xFFFF8200) : Color(0xFF333333), highlight ? Color(0xFFFF8200) : Color(0xFF333333),

@ -3,3 +3,4 @@ export 'package:akuCommunity/extensions/num_ext.dart';
export 'package:akuCommunity/extensions/widget_list_ext.dart'; export 'package:akuCommunity/extensions/widget_list_ext.dart';
export 'package:velocity_x/velocity_x.dart'; export 'package:velocity_x/velocity_x.dart';
export 'package:akuCommunity/const/resource.dart'; export 'package:akuCommunity/const/resource.dart';
export 'package:flutter_gen/gen_l10n/app_localizations.dart';

@ -416,7 +416,7 @@ packages:
source: hosted source: hosted
version: "4.4.2" version: "4.4.2"
intl: intl:
dependency: transitive dependency: "direct main"
description: description:
name: intl name: intl
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"

@ -12,6 +12,7 @@ dependencies:
sdk: flutter sdk: flutter
flutter_localizations: flutter_localizations:
sdk: flutter sdk: flutter
intl: ^0.17.0
permission_handler: ^6.1.1 permission_handler: ^6.1.1
package_info: ^2.0.0 package_info: ^2.0.0
provider: ^5.0.0 provider: ^5.0.0
@ -75,6 +76,7 @@ dev_dependencies:
flutter: flutter:
uses-material-design: true uses-material-design: true
generate: true
assets: assets:
- assets/ - assets/

Loading…
Cancel
Save