简体   繁体   English

Flutter 轻松本地化不会更改底部导航栏项目的标题

[英]Flutter Easy Localization Doesn't Change Bottom Navigation Bar Item's Titles

I am using easy_localization 3.0.1 for use several language in my app.我正在使用easy_localization 3.0.1在我的应用程序中使用多种语言。

main file have 4 pages to navigate and I am using bottom navigation bar to change body of this file.主文件有 4 个页面可供导航,我正在使用底部导航栏来更改此文件的主体。

In Profile page I should have change language of the app with button在个人资料页面中,我应该使用按钮更改应用程序的语言

onPressed:(){context.setLocale(Locale("tr", "TR"));}

but with this function the title's of the bottom navigation bar items are not changing.但是这个 function 底部导航栏项目的标题没有改变。 When I use setState they are changing but i need to make it without setState当我使用setState时,它们正在改变,但我需要在没有 setState 的情况下进行

You can use Getx, GetX Translation is best option for localization您可以使用 Getx,GetX 翻译是本地化的最佳选择

return GetMaterialApp(
    translations: Messages(),  
    locale: Locale('tr', 'TR'),  
     
);

Using translation with parameters使用带参数的翻译

Map<String, Map<String, String>> get keys => {
    'en_US': {
        'logged_in': 'logged in as @name with email @email',
    },
    'tr_TR': {
       'logged_in': '@name ile e-posta @email olarak giriş yaptı',
    }
};

Change locale更改语言环境

var locale = Locale('tr', 'TR');
Get.updateLocale(locale);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter 快速操作更改选定的底部导航栏项目 - Flutter Quick Actions change selected Bottom Navigation Bar item 底部导航栏无法正常工作 Flutter - Bottom Navigation Bar doesn't work correctly Flutter Flutter中的自定义底部导航栏项目装饰 - Custom Bottom Navigation Bar Item Decoration in Flutter 颤动底部导航栏使项目没有路线 - Flutter bottom navigation bar make item with no route 按 fab 更改底部导航栏选定的项目 - Change Bottom Navigation Bar selected Item by fab Flutter - 单击底部导航栏项目打开模态底部工作表 - Flutter - Open Modal Bottom Sheet on Bottom navigation bar item click 如何在flutter中不在导航项列表中的页面中显示底部导航栏? - How to show bottom navigation bar in page that is not in the navigation item list in flutter? 固定类型时,根据Flutter中选择的项目更改整个底部导航栏的背景颜色 - Change the background color of the entire bottom navigation bar depending on item selected in Flutter when type is fixed Flutter 底部导航栏 - Flutter Bottom Navigation Bar 单击底部导航栏项(并加载相关页面)时隐藏底部导航栏 - Flutter - Hide the bottom navigation bar when clicking on one bottom navigation bar item (and loading related page) - Flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM