| 322 | static wxString sLocaleName; |
| 323 | |
| 324 | wxString SetLang( const FilePaths &pathList, const wxString & lang ) |
| 325 | { |
| 326 | wxString result = lang; |
| 327 | |
| 328 | sLocale.reset(); |
| 329 | |
| 330 | #if defined(__WXMAC__) |
| 331 | // This should be reviewed again during the wx3 conversion. |
| 332 | |
| 333 | // On OSX, if the LANG environment variable isn't set when |
| 334 | // using a language like Japanese, an assertion will trigger |
| 335 | // because conversion to Japanese from "?" doesn't return a |
| 336 | // valid length, so make OSX happy by defining/overriding |
| 337 | // the LANG environment variable with U.S. English for now. |
| 338 | wxSetEnv(wxT("LANG"), wxT("en_US.UTF-8")); |
| 339 | #endif |
| 340 | |
| 341 | const wxLanguageInfo *info = NULL; |
| 342 | if (!lang.empty() && lang != wxT("System")) { |
| 343 | // Try to find the given language |
| 344 | info = wxLocale::FindLanguageInfo(lang); |
| 345 | } |
| 346 | if (!info) |
| 347 | { |
| 348 | // Not given a language or can't find it; substitute the system language |
| 349 | result = Languages::GetSystemLanguageCode(pathList); |
| 350 | info = wxLocale::FindLanguageInfo(result); |
| 351 | if (!info) |
| 352 | // Return the substituted system language, but we can't complete setup |
| 353 | // Should we try to do something better? |
| 354 | return result; |
| 355 | } |
| 356 | sLocale = std::make_unique<wxLocale>(info->Language); |
| 357 | |
| 358 | for( const auto &path : pathList ) |
| 359 | sLocale->AddCatalogLookupPathPrefix( path ); |
| 360 | |
| 361 | // LL: Must add the wxWidgets catalog manually since the search |
| 362 | // paths were not set up when mLocale was created. The |
| 363 | // catalogs are search in LIFO order, so add wxstd first. |
| 364 | sLocale->AddCatalog(wxT("wxstd")); |
| 365 | |
| 366 | // Must match TranslationExists() in Languages.cpp |
| 367 | sLocale->AddCatalog("audacity"); |
| 368 | |
| 369 | // Initialize internationalisation (number formats etc.) |
| 370 | // |
| 371 | // This must go _after_ creating the wxLocale instance because |
| 372 | // creating the wxLocale instance sets the application-wide locale. |
| 373 | |
| 374 | Internat::Init(); |
| 375 | |
| 376 | using future1 = decltype( |
| 377 | // The file of unused strings is part of the source tree scanned by |
| 378 | // xgettext when compiling the catalog template audacity.pot. |
| 379 | // Including it here doesn't change that but does make the C++ compiler |
| 380 | // check for correct syntax, but also generate no object code for them. |
| 381 | #include "FutureStrings.h" |
no test coverage detected