HTML文件本地化 [英] HTML File Localization

查看:181
本文介绍了HTML文件本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功完成了我的HTML文件的本地化。但是,当我尝试使用伪本地化[通过更改模拟器的语言]时,它仍然显示英文版的HTML文件。

所以我追踪了这个问题。我的一个HTML文件在所有语言中工作正常。
使用下面的代码获取它:

NSString * htmlFile = [[NSBundle mainBundle] pathForResource:@aboutofType:@ htmlinDirectory:nil forLocalization:[userPrefered objectAtIndex:0]];



我将htmlFile路径作为 -



/ Users / Tushar / Library / Developer / CoreSimulator / Devices / F607AED8-BC01-48DE-B3D0-BC3C028BBB23 / data / Containers / Bundle / Application / 8AB487BF-3CC2-4FC9-8371-D3AAB4955D05 / APP_NAME.app/hu.lproj/about.html b
$ b

但是,对于另一个HTML文件,我将htmlFile路径作为 -



/Users/Tushar/Library/Developer/CoreSimulator/Devices/F607AED8-BC01-48DE-B3D0-BC3C028BBB23/data/Containers/Bundle/Application/8AB487BF-3CC2-4FC9-8371-D3AAB4955D05/APP_NAME.app/disclaimer .html



显然,如果您观察到第二个htmlFile文件路径中缺少'hu.lproj /',这是造成此问题的原因。我不明白为什么会发生这种情况。



请帮助我。



非常感谢。

解决方案

最后,我解决了这个问题。如果其他人面临同样的问题。我不知道为什么,但方法,

  NSString * htmlFile = [[NSBundle mainBundle] pathForResource:@aboutofType: @htmlinDirectory:nil forLocalization:[userPrefered objectAtIndex:0]]; 

无法正常工作。

我改变了方法为

  NSString * htmlFile = [[NSBundle mainBundle] pathForResource:@aboutofType:@html inDirectory:[[userPrefered objectAtIndex:0] stringByAppendingPathExtension:@lproj]]; 

现在它的工作非常好。



希望这可以帮助别人。


I have successfully done localization of my HTML file. However, when I am trying with pseudo-localization [By changing language of simulator], it still shows a English version of HTML file.

So I track down the issue. One of my HTML file is working fine with all languages. While fetching it with following code

NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"html" inDirectory:nil forLocalization:[userPrefered objectAtIndex:0]];

I am getting htmlFile path as -

/Users/Tushar/Library/Developer/CoreSimulator/Devices/F607AED8-BC01-48DE-B3D0-BC3C028BBB23/data/Containers/Bundle/Application/8AB487BF-3CC2-4FC9-8371-D3AAB4955D05/APP_NAME.app/hu.lproj/about.html

But, for another HTML file I am getting htmlFile path as -

/Users/Tushar/Library/Developer/CoreSimulator/Devices/F607AED8-BC01-48DE-B3D0-BC3C028BBB23/data/Containers/Bundle/Application/8AB487BF-3CC2-4FC9-8371-D3AAB4955D05/APP_NAME.app/disclaimer.html

Clearly, if you observe, 'hu.lproj/' is missing in second htmlFile file path, which is creating this issue. I am not getting why is this happening.

Please help me.

Thanks in advance.

解决方案

Finally, I solved this issue. In case if anybody else face the same issue. I dont know why, but the method,

NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"html" inDirectory:nil forLocalization:[userPrefered objectAtIndex:0]];

is not working properly.

So I changed the method to

NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"about" ofType:@"html" inDirectory:[[userPrefered objectAtIndex:0] stringByAppendingPathExtension:@"lproj"]];

And now its working absolutely fine.

Hope this would help someone.

这篇关于HTML文件本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆