简体   繁体   English

如何解决本地化问题?

[英]How to solve localisation issue?

I am developing an app in Swift which supports two languages ie English and Norwegian. 我正在用Swift开发一个应用程序,它支持两种语言,即英语和挪威语。 I have gone through the documentation of Apple and applied the concept of Localizable.string and Localizable files for storyboard. 我浏览了Apple的文档,并为演示图板应用了Localizable.string和Localizable文件的概念。

Now, I have an issue where a client wants to have whole app in Norwegian irrespective of system language. 现在,我遇到一个问题,无论系统语言如何,客户都希望使用挪威语编写整个应用程序。 I can achieve it by taking reference of each object in controller file and then assigning text based on localised string. 我可以通过引用控制器文件中的每个对象,然后基于本地化字符串分配文本来实现。

Could you please suggest more efficient way to handle this? 您能否提出更有效的方法来解决这个问题?

Thanks in advance. 提前致谢。 这是我的项目的屏幕截图

Credit to marmelroy for this code https://github.com/marmelroy/Localize-Swift which can Localize from within the app. 感谢marmelroy提供此代码https://github.com/marmelroy/Localize-Swift ,该代码可在应用程序内进行本地化。

For your specific case, 对于您的具体情况,

1) You will simply need to drag and drop the required files from the above source 1)您只需要从上述源中拖放所需的文件

2) Set a line in didFinishLaunchingWithOptions 2)在didFinishLaunchingWithOptions设置一行

// For Norwegian Nynorsk language.
Localize.setCurrentLanguage("nn")

This will set the current language to the needed one and will always show you the app in specified language. 这会将当前语言设置为所需的语言,并始终以指定的语言向您显示该应用。

Hope it helps! 希望能帮助到你!

EDIT 编辑

I tried the same and it's showing the auto suggestions for Localize.set 我尝试了同样的方法,它显示了Localize.set的自动建议 试过一样

请参阅此GitHub链接以在运行时更改应用程序的本地化。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM