翻译后如何对数组进行排序?
我有一个下拉菜单,其中包含来自后端的国家/地区列表。我使用 i18n 本地化来翻译它们。它们按英文字母顺序排列,下拉列表正确显示英语国家/地区列表。
当我以其他语言运行该平台时,它们会被正确翻译,但问题是它们保持英文排序。
有没有办法在应用 i18n 翻译后按字母顺序对国家/地区列表进行排序?
谢谢 :)
I have a dropdown with a list of countries coming from the back-end. I translate them using i18n localisation. They arrive alphabetically ordered in English and the dropdown correctly shows the list of English countries.
When I run the platform in other languages, they are translated correctly, but the problem is that they keep the English sorting.
Is there a way to sort the list of countries alphabetically after the i18n translation is applied?
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用排序管道:
}
有一个 Stackbliz 示例:
角度排序管道 Stackblits
You can use sort pipe :
}
There is a Stackbliz sample:
Angular sort pipe Stackblits