ionic-framework - Ionic 4. 替代 platform.lang()
问题描述
我正在检查离子 4 的平台文档(https://ionicframework.com/docs/utilities/platform),我看到离子 3 中可用的 lang() 函数(https://ionicframework.com/docs/ v3/api/platform/Platform/)未实现。
有没有其他选择?我正在尝试将 ionic 3 项目迁移到 4,我有以下代码来检测用户的语言
const browserLanguage = navigator.language || this.platform.lang();
提前致谢!
解决方案
您可以使用全球化插件
this.globalization.getPreferredLanguage()
.then(res => console.log(res))
.catch(e => console.log(e));
推荐阅读
- javascript - 当我不希望它时,Visual Code 自动格式会放置新行
- sql - Teradata SQL - CREATE table as select - 表填充的结果集与手动运行查询不同
- angular6 - 如何在 ngOnInit 获得 localstorage 的值
- python - Python随机生成每个实例的种子
- arrays - 在 Matlab 中使用匿名 fnc 时如何将值存储到数组中以绘制它们
- game-maker - GameMaker Studio 2 - 中心 + 钳位相机变焦
- tensorflow - 从 tfrecords 中的不平衡数据生成平衡批次
- php - 如何在 html 和 php 中制作 PIVOT(Crosstab)
- amazon-web-services - AWS 和 kubernetes 卷 - 如何跨多个 Pod 共享配置?
- stanford-nlp - CoreNLP:为什么输出结果只包含单独的字母而不是单独的单词?