Skip to content

Commit

Permalink
fix: wxWidgets: pt_BR zh_CN zh_TW translation not works on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeWang000000 committed Feb 5, 2025
1 parent 60428c9 commit b05e857
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dist/win/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ FFMPEG_SHA="fd59e6160476095082e94150ada5a6032d7dcc282fe38ce682a00c18e7820528"

PREFIX="$MINGW_PREFIX"

pacman -Sy && pacman -S --needed --noconfirm autotools intltool yasm zip "${MINGW_PACKAGE_PREFIX}-toolchain"
pacman -Sy && pacman -S --needed --noconfirm autotools patch intltool yasm zip "${MINGW_PACKAGE_PREFIX}-toolchain"

rm -rf $(dirname $0)/deps
mkdir -p $(dirname $0)/deps
Expand All @@ -27,6 +27,10 @@ wget "$WX_URL"
echo "$WX_SHA wxWidgets-$WX_VER.tar.bz2" | sha256sum -c
tar xf "wxWidgets-${WX_VER}.tar.bz2"
cd "wxWidgets-${WX_VER}"

# fix: pt_BR zh_CN zh_TW translation not works
patch -p1 < ../../wx-translation.patch

mkdir msw-build
cd msw-build
../configure \
Expand Down
51 changes: 51 additions & 0 deletions dist/win/wx-translation.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
diff --git a/src/common/translation.cpp b/src/common/translation.cpp
index 30b1ca42dc..a64778061a 100644
--- a/src/common/translation.cpp
+++ b/src/common/translation.cpp
@@ -1398,11 +1398,12 @@ bool wxTranslations::AddStdCatalog()
// the name without the version if it's not found, as message catalogs
// typically won't have the version in their names under non-Unix platforms
// (i.e. where they're not installed by our own "make install").
- wxString domain("wxstd-" wxSTRINGIZE(wxMAJOR_VERSION) "." wxSTRINGIZE(wxMINOR_VERSION));
- if ( GetBestAvailableTranslation(domain).empty() )
- domain = wxS("wxstd");
+ if ( AddAvailableCatalog("wxstd-" wxSTRINGIZE(wxMAJOR_VERSION) "." wxSTRINGIZE(wxMINOR_VERSION)) )
+ return true;
+ if ( AddCatalog(wxS("wxstd")) )
+ return true;

- return AddCatalog(domain);
+ return false;
}

#if !wxUSE_UNICODE
@@ -1577,28 +1578,7 @@ wxString wxTranslations::DoGetBestAvailableTranslation(const wxString& domain, c

if ( !m_lang.empty() )
{
- wxLogTrace(TRACE_I18N,
- "searching for best translation to %s for domain '%s'",
- m_lang, domain);
-
- wxString lang;
- if ( available.Index(m_lang) != wxNOT_FOUND )
- {
- lang = m_lang;
- }
- else
- {
- const wxString baselang = m_lang.BeforeFirst('_');
- if ( baselang != m_lang && available.Index(baselang) != wxNOT_FOUND )
- lang = baselang;
- }
-
- if ( lang.empty() )
- wxLogTrace(TRACE_I18N, " => no available translations found");
- else
- wxLogTrace(TRACE_I18N, " => found '%s'", lang);
-
- return lang;
+ return m_lang;
}

wxLogTrace(TRACE_I18N, "choosing best language for domain '%s'", domain);

0 comments on commit b05e857

Please sign in to comment.