I am making an iOS app, and I have this problem.
- My app most be only in Spanish, so i changed the development language (in the hard way, changing the
developmentRegion = es;
inside the theproject.pbxproj
and changing theCFBundleDevelopmentRegion=es
in theInfo.plist
) - I also add a
Localizable.strings
to my only language (es) to have all theStrings
inside one document. And all myNSLocalizedStrings
works fine
The problem comes out when i use the function HTTPURLResponse.localizedString(forStatusCode:)
it only give me back Strings
in English. Previously works fine, but after added the Localizable.string
don't work well anymore
Any help to bring back the Strings
to Spanish??
I think you are missing the correct approach.
You don't need to localise low level network error as:
For III point:
}
If you got a BIG error (for example in my code I used a wrong prefix, "__https") You will get _code = -1022,
and You can manage this way:
Where You can mask out message to final user and make it more general (and localised using a convenience function "localized")
For HTTP error (for example not found resource... i.e. "https://ingconti.com/wrongurl") You will get error 404 in http/s.
So you can do similar:
final private func manageHTTPError(code: Int, data : Data?){ guard let data = data else{ return }
Or even merged toghether.
(string s in
#if DEBUG if let s = .....
will show server error, and again do not show to user...)
to sum up: so not show low level error, see gentle message, so for example in you localized strings You can have:
"GENERIC_NETWORK_ERR" = "Network error"; "NETWORK_CODE_404". = "Network error (no data)";
and in spanish...
"GENERIC_NETWORK_ERR" = "error de red "; ...
Hope it can help.