Skip to content

Instantly share code, notes, and snippets.

View j4johnfox's full-sized avatar

John C Fox j4johnfox

View GitHub Profile
- (CPString)browserLanguage
{
// IE uses userLanguage to return the code. For now, we'll just deal with
// the "base" language (e.g. "en" vs. "en-GB"
var userLang = (navigator.language) ? navigator.language : navigator.userLanguage;
return userLang.substring(0,2)
}
- (CPString)bundleLocaleWithUserLanguage:(CPString)aUserLanguage
{
var defaultLocale = [self objectForInfoDictionaryKey:@"CPBundleDevelopmentRegion"];
var availableLocales = [self objectForInfoDictionaryKey:@"CPBundleLocalizedResourceKeys"];
var bestMatch, myLocale= nil;
UserLanguage = aUserLanguage;
// First try matching against the UserLanguage
if (UserLanguage && [UserLanguage length])