I'm trying to perform a simple task in XCode of checking whether a certain NSString language matches the user's preferred language.
For example, let's say I have a string such as the following:
NSString *englishString = @"Good morning!";
NSString *frenchString = @"Bonjour!";
I know I can get the user device's preferred language using the NSLocaleLanguageCode value, and based on a previous Stack Overflow answer here, I can get the language of the NSString. However, when I compare the two values, the keys don't seem to match. Is there a better way to go about implementing this? Thanks!
The documentation for NSLocaleLanguageCode can be found here and the description for NSLinguisticTagger can be found here. NSLocaleLanguageCode returns an NSString while the tagger, and in particular, the "tagAtIndex" method returns an NSLinguisticTag key.