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 70131bf
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 4 deletions.
23 changes: 19 additions & 4 deletions 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 All @@ -45,16 +49,27 @@ make -j$(nproc) && make install
cd ../..

# === FFmpeg ===
# There are some problems assembling aarch64 code. Just disable it.
[ "$MSYSTEM" = "CLANGARM64" ] && FFMPEG_ASM_OPTION="--disable-asm" || FFMPEG_ASM_OPTION=""
echo "# Installing FFmpeg..."
if gcc -v >/dev/null 2>&1; then
CC=gcc
elif clang -v >/dev/null 2>&1; then
CC=clang
else
CC=cc
fi
if [ "$MSYSTEM" = "CLANGARM64" ]; then
ARCH=arm64
else
ARCH=x86_64
fi
wget "$FFMPEG_URL"
echo "$FFMPEG_SHA ffmpeg-${FFMPEG_VER}.tar.bz2" | sha256sum -c
tar xf "ffmpeg-${FFMPEG_VER}.tar.bz2"
cd "ffmpeg-${FFMPEG_VER}"
./configure \
--prefix="$PREFIX" \
$FFMPEG_ASM_OPTION \
--cc="$CC" \
--arch="$ARCH" \
--enable-version3 \
--enable-gpl \
--disable-programs \
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 70131bf

Please sign in to comment.