1、加入依赖ios
flutter_i18n: ^0.8.2 flutter_localizations: sdk: flutter
2、引用git
{ "appName": "EasyRefresh", "sample": "Sample", "style": "Style", "more": "More", "basicUse": "BasicUse", "basicUseDescribe": "Basic use of EasyRefresh", "manualControl": "Manual control", "manualControlDescribe": "Control the timing of completion of refresh and load", "refresh": "Refresh", "loadMore": "LoadMore", "pullToRefresh": "Pull to refresh", "releaseToRefresh": "Release to refresh", "refreshing": "Refreshing...", "refreshFinish": "Refresh completed", "refreshFailed": "Refresh failed", "refreshed": "Refresh completed", "pushToLoad": "Pull to load", "releaseToLoad": "Release to load", "loading": "Loading...", "loadFinish": "Load completed", "loaded": "Load completed", "loadFailed": "Load failed", "completeRefresh": "Refresh done", "completeLoad": "Load done", "noMore": "No more", "updateAt": "Update at %T", "autoLoad": "Auto load", "autoLoadDescribe": "Automatically refresh the slide to the bottom", "floatView": "Floating view", "floatViewDescribe": "At the top or bottom view floating on the list", "userProfile": "User Profile", "userProfileDescribe": "User Profile with the springback effect", "customScrollViewDescribe": "List with AppBar Folding, listener example", "swiperDescribe": "Swiper example, resolve sliding conflicts", "listEmbed": "List embed", "listEmbedDescribe": "Use the connector to set the Header and Footer positions", "cupertinoDescribe": "ios style", "firstRefresh": "First refresh", "firstRefreshDescribe": "First refresh widget", "emptyWidget": "Empty widget", "emptyWidgetDescribe": "Show empty widget when there is no data", "tabViewWidgetDescribe": "List and Grid consist of TabBarView", "nestedScrollViewDescribe": "NestedScrollView example", "secondFloor": "Second floor", "secondFloorDescribe": "Imitate the second floor of Taobao", "welcomeToSecondFloor": "Welcome to second floor", "scrollBar": "ScrollBar", "scrollBarDescribe": "Add a scroll bar to the list", "qqGroup": "QQ group", "github": "Github", "name": "Name", "old": "Old", "noBald": "Has not the bald", "city": "City", "hangzhou": "China - HangZhou", "chengdu": "China - ChengDu", "phone": "Phone", "email": "E-Mail", "classic": "Classic", "classicDescribe": "Classic and default", "materialDescribe": "Material design, Android style", "ballPulseDescribe": "Ball pulse style", "bezierCircleDescribe": "Popup circle style", "bezierHourGlassDescribe": "Popup HourGlass style", "phoenixDescribe": "Golden campus", "taurusDescribe": "Rushing into the sky", "spaceDescribe": "Flare animation - Space", "deliveryDescribe": "Express balloon", "moreStyle": "More style", "moreStyleDescribe": "Come soon! You can also refer to the source code customization", "joinDiscussion": "Join the discussion", "joinDiscussionDescribe": "Join the QQ group 554981921", "projectAddress": "Project address", "supportAuthor": "Support the author", "supportAuthorDescribe": "Your support is my biggest motivation", "about": "About", "star": "Star project", "aliPay": "AliPay", "weiXinPay": "WeiXin Pay", "qqPay": "QQ Pay", "payPal": "PayPal", "noData": "No data", "direction": "Direction", "listDirection": "List direction", "vertical": "Vertical", "horizontal": "Horizontal", "reverse": "reverse", "listReverse": "List reverse", "infiniteLoad": "Infinite load", "infiniteLoadDescribe": "Slide to bottom trigger loading", "controlFinish": "Control finish", "controlFinishDescribe": "Using Controller to End Asynchronous Tasks", "taskIndependence": "Task independence", "taskIndependenceDescribe": "Refresh and load tasks are not affected by each other", "headerFloat": "Header float", "headerFloatDescribe": "Header is displayed on the list", "vibration": "vibration", "vibrationDescribe": "Triggered vibration feedback", "refreshSwitch": "Refresh switch", "refreshSwitchDescribe": "Whether to turn on refresh", "loadSwitch": "Load switch", "loadSwitchDescribe": "Whether to turn on load", "linkHeader": "Header linker", "linkHeaderDescribeDescribe": "Customize Header with linker", "topBouncing": "Top bouncing", "topBouncingDescribe": "Top can be crossed", "bottomBouncing": "Bottom bouncing", "bottomBouncingDescribe": "Bottom can be crossed", "chatPage": "Chat page", "chatPageDescribe": "Chat page example", "send": "Send", "me": "Me", "bobMinion": "Bob minion", "bobMinionDescribe": "Cute yellow Minions" }
{ "appName": "EasyRefresh", "sample": "示例", "style": "样式", "more": "更多", "basicUse": "基本使用", "basicUseDescribe": "EasyRefresh的基本使用", "manualControl": "手动控制", "manualControlDescribe": "控制刷新和加载的完成时机", "refresh": "刷新", "loadMore": "加载", "pullToRefresh": "拉动刷新", "releaseToRefresh": "释放刷新", "refreshing": "正在刷新...", "refreshFinish": "刷新完成", "refreshFailed": "刷新失败", "refreshed": "刷新完成", "pushToLoad": "拉动加载", "releaseToLoad": "释放加载", "loading": "正在加载...", "loadFinish": "加载完成", "loadFailed": "加载失败", "loaded": "加载完成", "noMore": "没有更多数据", "completeRefresh": "完成刷新", "completeLoad": "完成加载", "updateAt": "更新于 %T", "autoLoad": "自动加载", "autoLoadDescribe": "滑到底部自动刷新", "floatView": "浮动视图", "floatViewDescribe": "顶部或底部视图浮动在列表上", "userProfile": "我的中心", "userProfileDescribe": "带回弹效果的我的中心", "customScrollViewDescribe": "带头部折叠的列表,监听器示例", "swiperDescribe": "Swiper示例,解决滑动冲突", "listEmbed": "列表嵌入", "listEmbedDescribe": "使用链接器设置Header和Footer位置", "cupertinoDescribe": "ios风格", "firstRefresh": "首次刷新", "firstRefreshDescribe": "首次刷新视图", "emptyWidget": "空视图", "emptyWidgetDescribe": "没有数据时显示空视图", "tabViewWidgetDescribe": "List和Grid组成的TabBarView", "nestedScrollViewDescribe": "NestedScrollView示例", "secondFloor": "二楼", "secondFloorDescribe": "模仿淘宝二楼", "welcomeToSecondFloor": "欢迎来到二楼", "scrollBar": "滚动条", "scrollBarDescribe": "为列表添加滚动条", "qqGroup": "QQ群", "github": "Github", "name": "名字", "old": "年龄", "noBald": "没到秃头的年龄", "city": "城市", "hangzhou": "中国 - 杭州", "chengdu": "中国 - 成都", "phone": "电话", "email": "邮箱", "classic": "经典样式", "classicDescribe": "经典(默认)风格", "materialDescribe": "质感设计,Android样式", "ballPulseDescribe": "球脉冲样式", "bezierCircleDescribe": "弹出圆圈", "bezierHourGlassDescribe": "弹出HourGlass", "phoenixDescribe": "金色校园", "taurusDescribe": "冲上云霄", "spaceDescribe": "Flare动画 - 星空", "deliveryDescribe": "气球快递", "moreStyle": "更多样式", "moreStyleDescribe": "会愈来愈多哦!你也能够参考源码自定义", "joinDiscussion": "加入讨论", "joinDiscussionDescribe": "加入QQ群554981921,进行讨论", "projectAddress": "项目地址", "supportAuthor": "支持做者", "supportAuthorDescribe": "你的支持是我最大的动力", "about": "关于", "star": "Star 项目", "aliPay": "支付宝", "weiXinPay": "微信钱包", "qqPay": "QQ钱包", "payPal": "PayPal", "noData": "没有数据", "direction": "方向", "listDirection": "列表方向", "vertical": "垂直", "horizontal": "水平", "reverse": "反向", "listReverse": "列表反向", "infiniteLoad": "无限加载", "infiniteLoadDescribe": "滑动到底部自动触发加载", "controlFinish": "控制结束", "controlFinishDescribe": "使用控制器结束异步任务", "taskIndependence": "任务独立", "taskIndependenceDescribe": "刷新和加载任务互不受影响(不推荐)", "headerFloat": "Header浮动", "headerFloatDescribe": "Header显示在列表之上", "vibration": "震动", "vibrationDescribe": "触发震动反馈", "refreshSwitch": "刷新开关", "refreshSwitchDescribe": "是否开启刷新", "loadSwitch": "加载开关", "loadSwitchDescribe": "是否开启加载", "linkHeader": "Header链接器", "linkHeaderDescribeDescribe": "使用链接器自定义Header", "topBouncing": "顶部回弹", "topBouncingDescribe": "顶部可越界", "bottomBouncing": "底部回弹", "bottomBouncingDescribe": "底部可越界", "chatPage": "聊天页面", "chatPageDescribe": "模仿聊天页面", "send": "发送", "me": "我", "bobMinion": "Bob小黄人", "bobMinionDescribe": "可爱的小黄人" }
3、在pubspec.yaml中声明github
- assets/locale/
4、在main.dart的build方法中设置代理spring
import 'package:flutter_i18n/flutter_i18n_delegate.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
localizationsDelegates: [ FlutterI18nDelegate( useCountryCode: true, fallbackFile: 'zh_CN', path: 'assets/locale'), GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate ], localeResolutionCallback: (local, supportedLocales) { return local; }
5、使用微信
import 'package:flutter_i18n/flutter_i18n.dart';
loadingText: FlutterI18n.translate(context, 'loading'),
参考:app
https://github.com/xuelongqy/flutter_easyrefresh/blob/v2/example/lib/page/sample/basic.dart异步