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異步