@@ -293,6 +293,12 @@ wxString PoeditApp::GetAppVersion() const
293
293
return wxString::FromAscii (POEDIT_VERSION);
294
294
}
295
295
296
+ wxString PoeditApp::GetMajorAppVersion () const
297
+ {
298
+ auto v = wxSplit (GetAppVersion (), ' .' );
299
+ return wxString::Format (" %s.%s" , v[0 ], v[1 ]);
300
+ }
301
+
296
302
wxString PoeditApp::GetAppBuildNumber () const
297
303
{
298
304
#if defined(__WXOSX__)
@@ -631,18 +637,29 @@ void PoeditApp::SetupLanguage()
631
637
#endif
632
638
633
639
#ifdef SUPPORTS_OTA_UPDATES
634
- SetupOTALanguageUpdate (trans, str::to_utf8 ( bestTrans) );
640
+ SetupOTALanguageUpdate (trans, bestTrans);
635
641
#endif
636
642
}
637
643
638
644
#ifdef SUPPORTS_OTA_UPDATES
639
- void PoeditApp::SetupOTALanguageUpdate (wxTranslations *trans, const std::string & lang)
645
+ void PoeditApp::SetupOTALanguageUpdate (wxTranslations *trans, const wxString & lang)
640
646
{
641
647
if (lang == " en" )
642
648
return ;
643
649
650
+ // normalize language code for requests
651
+ wxString langMO (lang);
652
+ if (langMO == " zh-Hans" )
653
+ langMO = " zh_CN" ;
654
+ else if (langMO == " zh-Hant" )
655
+ langMO = " zh_TW" ;
656
+ else
657
+ langMO.Replace (" -" , " _" );
658
+
659
+ auto version = str::to_utf8 (GetMajorAppVersion ());
660
+
644
661
// use downloaded OTA translations:
645
- auto dir = GetCacheDir (" Translations" ) + " /" + POEDIT_VERSION ;
662
+ auto dir = GetCacheDir (" Translations" ) + " /" + version ;
646
663
wxFileTranslationsLoader::AddCatalogLookupPathPrefix (dir);
647
664
trans->AddCatalog (" poedit-ota" );
648
665
@@ -663,7 +680,7 @@ void PoeditApp::SetupOTALanguageUpdate(wxTranslations *trans, const std::string&
663
680
if (!etag.empty ())
664
681
hdrs.emplace_back (" If-None-Match" , etag);
665
682
666
- http_client::download_from_anywhere (" https://ota.poedit.net/i18n/" POEDIT_VERSION " /" + lang + " /poedit-ota.mo.gz" , hdrs)
683
+ http_client::download_from_anywhere (" https://ota.poedit.net/i18n/" + version + " /" + str::to_utf8 (langMO) + " /poedit-ota.mo.gz" , hdrs)
667
684
.then_on_main ([=](downloaded_file f)
668
685
{
669
686
TempOutputFileFor temp (mofile);
0 commit comments