From 6220fd7da99b2edf6b1c6e98e65b45216a32e7af Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 29 Dec 2016 21:24:46 -0800 Subject: Apparently, setlocale never actually did anything. --- MobileCydia.mm | 43 +++++++++++++++++++++++-------------------- apt | 2 +- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/MobileCydia.mm b/MobileCydia.mm index d25e070..2a694ee 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -10304,29 +10304,28 @@ int main(int argc, char *argv[]) { Locale_ = CFLocaleCopyCurrent(); Languages_ = [NSLocale preferredLanguages]; - //CFStringRef locale(CFLocaleGetIdentifier(Locale_)); - //NSLog(@"%@", [Languages_ description]); + std::string languages; + const char *translation(NULL); - const char *lang; + // XXX: this isn't really a language, but this is compatible with older Cydia builds if (Locale_ != NULL) - lang = [(NSString *) CFLocaleGetIdentifier(Locale_) UTF8String]; - 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; - - if (lang != NULL) { - RegEx pattern("([a-z][a-z])(?:-[A-Za-z]*)?(_[A-Z][A-Z])?"); - lang = !pattern(lang) ? NULL : [pattern->*@"%1$@%2$@" UTF8String]; - } + if (const char *language = [(NSString *) CFLocaleGetIdentifier(Locale_) UTF8String]) { + RegEx pattern("([a-z][a-z])(?:-[A-Za-z]*)?(_[A-Z][A-Z])?"); + if (pattern(language)) { + translation = strdup([pattern->*@"%1$@%2$@" UTF8String]); + languages += translation; + languages += ","; + } + } - NSLog(@"Setting Language: %s", lang); + if (Languages_ != nil) + for (NSString *language : Languages_) { + languages += [language UTF8String]; + languages += ","; + } - if (lang != NULL) { - setenv("LANG", lang, true); - setlocale(LC_ALL, lang); - } + languages += "en"; + NSLog(@"Setting Language: %s", languages.c_str()); /* }}} */ /* Index Collation {{{ */ if (Class $UILocalizedIndexedCollation = objc_getClass("UILocalizedIndexedCollation")) { @try { @@ -10577,7 +10576,11 @@ int main(int argc, char *argv[]) { _config->Set("Dir::Bin::Methods::store", "/Applications/Cydia.app/store"); _config->Set("pkgCacheGen::ForceEssential", ""); - _config->Set("APT::Acquire::Translation", "environment"); + + if (translation != NULL) + _config->Set("APT::Acquire::Translation", translation); + if (!languages.empty()) + _config->Set("Acquire::Languages", languages); // XXX: this timeout might be important :( //_config->Set("Acquire::http::Timeout", 15); diff --git a/apt b/apt index 1242b3b..22c5f99 160000 --- a/apt +++ b/apt @@ -1 +1 @@ -Subproject commit 1242b3bdaf3d3682a945f10f0e537bdb3b0599d5 +Subproject commit 22c5f99a6119eeef30e1ddee3262bc942d055455 -- cgit v1.2.3