Asihttprequest localizedDescription always in English

微笑、不失礼 提交于 2019-12-06 15:34:08

问题


im using Asihttprequest for my HTTP request, and my app will handel 3 language : arabic, french and english but Asihttprequest error localizedDescription return always an english description. is Asihttprequest request use the default ios systeme localisation description? if yes how can i localize error ? thank you.


回答1:


I am not sure of what exactly you asked for, but you can try this.

In the ASIHttpRequest.m file Initialize method use NSLocalizedString(@"REQUESTTIMEOUT_KEY", @"The request timed out") instead of @"The request timed out".

Have the "REQUESTTIMEOUT_KEY" = "EngVersion:The request timed out"; in the corresponding localizable.strings file.

Sample Code:

ASIRequestTimedOutError = [[NSError alloc] initWithDomain:NetworkRequestErrorDomain code:ASIRequestTimedOutErrorType userInfo:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"REQUESTTIMEOUT_KEY", @"The request timed out"),NSLocalizedDescriptionKey,nil]]; 


来源:https://stackoverflow.com/questions/9354353/asihttprequest-localizeddescription-always-in-english

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!