summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2011-02-27 14:42:07 -0800
committerJay Freeman (saurik) <saurik@saurik.com>2011-03-07 02:41:26 -0800
commit3caee0a42f7858b467eca791848fc817162ab98d (patch)
tree95b37f7bee9b8f1b6a3e689bd8a9296f658c4e58
parent3894bd28cb68484b6105a16823901c00433fe4ce (diff)
I really really hate these locale codes.
-rw-r--r--MobileCydia.mm17
1 files changed, 12 insertions, 5 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 731f6aa..10f47fd 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -10157,16 +10157,23 @@ int main(int argc, char *argv[]) { _pooled
const char *lang;
if (Locale_ != NULL)
lang = [(NSString *) CFLocaleGetIdentifier(Locale_) UTF8String];
- else if (Languages_ == nil || [Languages_ count] == 0)
+ else if (Languages_ != nil && [Languages_ count] != 0)
+ lang = [[Languages_ objectAtIndex:0] UTF8String];
+ else
// XXX: consider just setting to C and then falling through?
lang = NULL;
- else {
- lang = [[Languages_ objectAtIndex:0] UTF8String];
- setenv("LANG", lang, true);
- std::setlocale(LC_ALL, lang);
+
+ if (lang != NULL) {
+ Pcre pattern("^([a-z][a-z])(?:-[A-Za-z]*)?(_[A-Z][A-Z])?$");
+ lang = !pattern(lang) ? NULL : [pattern->*@"%1$@%2$@" UTF8String];
}
NSLog(@"Setting Language: %s", lang);
+
+ if (lang != NULL) {
+ setenv("LANG", lang, true);
+ std::setlocale(LC_ALL, lang);
+ }
/* }}} */
apr_app_initialize(&argc, const_cast<const char * const **>(&argv), NULL);