1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Fix missing Spanish language choice on Linux...

... Don't modify a hash table (with operator []) while iterating it!
This commit is contained in:
Paul Licameli 2019-10-24 15:21:21 -04:00
parent b83ebc17a1
commit e96c213f4b

View File

@ -190,17 +190,20 @@ void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
wxArrayString tempNames; wxArrayString tempNames;
wxArrayString tempCodes; wxArrayString tempCodes;
LangHash localLanguageName;
LangHash reverseHash; LangHash reverseHash;
LangHash tempHash; LangHash tempHash;
for ( auto utf8Name : utf8Names ) const LangHash localLanguageName = []{
{ LangHash localLanguageName;
auto str = wxString::FromUTF8(utf8Name); for ( auto utf8Name : utf8Names )
auto code = str.BeforeFirst(' '); {
auto name = str.AfterFirst(' '); auto str = wxString::FromUTF8(utf8Name);
localLanguageName[code] = name; auto code = str.BeforeFirst(' ');
} auto name = str.AfterFirst(' ');
localLanguageName[code] = name;
}
return localLanguageName;
}();
auto audacityPathList = FileNames::AudacityPathList(); auto audacityPathList = FileNames::AudacityPathList();
@ -213,9 +216,8 @@ void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
// For each language in our list we look for a corresponding entry in // For each language in our list we look for a corresponding entry in
// wxLocale. // wxLocale.
for (LangHash::iterator i = localLanguageName.begin(); for ( auto end = localLanguageName.end(), i = localLanguageName.begin();
i != localLanguageName.end(); i != end; ++i )
i++)
{ {
const wxLanguageInfo *info = wxLocale::FindLanguageInfo(i->first); const wxLanguageInfo *info = wxLocale::FindLanguageInfo(i->first);
@ -242,11 +244,13 @@ void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
if (fullCode.length() < 2) if (fullCode.length() < 2)
continue; continue;
if (!localLanguageName[code].empty()) { auto found = localLanguageName.find( code );
name = localLanguageName[code]; if ( found != end ) {
name = found->second;
} }
if (!localLanguageName[fullCode].empty()) { found = localLanguageName.find( fullCode );
name = localLanguageName[fullCode]; if ( found != end ) {
name = found->second;
} }
if (TranslationExists(audacityPathList, fullCode)) { if (TranslationExists(audacityPathList, fullCode)) {