启用位置后,如何重新加载UI中的文本
我有一个基于位置本地化的应用程序。如果已经启用了设备位置,它可以完美地工作。但是,如果不是这样,我们在打开放映时要求征求位置许可。 TF用户点击是的,然后我想更改应用程序语言。在这种情况下,当前页面语言没有变化,语言更改将在其余页面中反映。
<Label Text={"lan:Translate Notification"}>
我正在绑定这样的静态文本。我已经提到了此博客:https://mindofai.github.io/implementing-localization-with-xamarin.forms/
I have an app with localization based on the location. It works perfectly if the device location is already enabled. But if it is not, we ask for location permission while opening the aplication. Tf the user clicks yes then I want to change the app language. In this case the current page language is not changing, and the language change will reflect in the remaining pages.
<Label Text={"lan:Translate Notification"}>
I am binding the static text like this. I have referred this blog: https://mindofai.github.io/Implementing-Localization-with-Xamarin.Forms/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以处理 xamarin forms in xamarin forms strong>批准文件,这些步骤是:
创建一个批准文件:
每种您要支持的每种语言添加一个RESX文件。 “它必须遵循特定的命名约定:使用与基本资源文件(例如批准)的文件名相同,然后使用一个(。)然后是语言代码”。
在批准文件中添加文本:代码,例如:
在代码中使用批准文件:
要使用批准文本,您必须在XAML中导入批准的类名称空间并加载并加载它通过使用静态参考。
这是一篇有关在xamarin.forms中掌握多语言 谈论您在添加多语言支持时可能会遇到的一些典型问题。
You can handle Multilingual in Xamarin forms with AppResource File,the steps are :
Create an AppResource File:
Add one resx file per each language you want to support. “It must follow a specific naming convention: use the same filename as the base resources file (eg. AppResources) followed by a period (.) and then the language code”.
Add your texts in your AppResources file: code like:
Use your AppResources file in your code:
To use your AppResource texts you have to import the AppResources class namespace in XAML and load it by using static reference.
Here is a article about Mastering Multilingual in Xamarin.Forms which talk about some typical problems that you might face when adding multilingual support .
当您启用位置服务时,您可以拥有当前的文化信息:
,如果您的应用程序以前运行,则可以在本地存储本地文化信息(即偏好存储),并在设置导航堆栈之前将先前已知的文化加载在App.cs上。
At the time you have the location service enabled and you've got the current culture info you can:
If your application had run before, you could store the culture info locally (i.e Preference storage) and load the previously known culture at the App.cs before setting the Navigation stack.