Strip mnemonics from CJK translations of menu items too
Chinese, Japanese etc translations use a special style for the menu mnemonics and append them to the translated menu label in brackets, e.g. the menu label could have the form of "<translation-of-file> (&F)". Check for this style of mnemonics in wxStripMenuCodes() too and strip them as well.
This commit is contained in:
committed by
Vadim Zeitlin
parent
423ad59b00
commit
13068d3603
@@ -1155,6 +1155,29 @@ wxString wxStripMenuCodes(const wxString& in, int flags)
|
|||||||
size_t len = in.length();
|
size_t len = in.length();
|
||||||
out.reserve(len);
|
out.reserve(len);
|
||||||
|
|
||||||
|
// In some East Asian languages _("&File") translates as "<translation>(&F)"
|
||||||
|
// Check for this first, otherwise fall through to the standard situation
|
||||||
|
if (flags & wxStrip_Mnemonics)
|
||||||
|
{
|
||||||
|
wxString label(in), accel;
|
||||||
|
int pos = in.Find('\t');
|
||||||
|
if (pos != wxNOT_FOUND)
|
||||||
|
{
|
||||||
|
label = in.Left(pos+1).Trim();
|
||||||
|
if (!(flags & wxStrip_Accel))
|
||||||
|
{
|
||||||
|
accel = in.Mid(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The initial '?' means we match "Foo(&F)" but not "(&F)"
|
||||||
|
if (label.Matches("?*(&?)") > 0)
|
||||||
|
{
|
||||||
|
label = label.Left( label.Len()-4 ).Trim();
|
||||||
|
return label + accel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for ( wxString::const_iterator it = in.begin(); it != in.end(); ++it )
|
for ( wxString::const_iterator it = in.begin(); it != in.end(); ++it )
|
||||||
{
|
{
|
||||||
wxChar ch = *it;
|
wxChar ch = *it;
|
||||||
|
@@ -391,7 +391,7 @@ COND_wxUSE_REGEX_builtin___LIB_REGEX_p = \
|
|||||||
|
|
||||||
### Targets: ###
|
### Targets: ###
|
||||||
|
|
||||||
all: test$(EXEEXT) $(__test_drawing___depname) $(__test_drawingplugin___depname) $(__test_gui___depname) $(__test_gui_bundle___depname) data data-images fr
|
all: test$(EXEEXT) $(__test_drawing___depname) $(__test_drawingplugin___depname) $(__test_gui___depname) $(__test_gui_bundle___depname) data data-images fr ja
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|
||||||
@@ -496,6 +496,18 @@ fr:
|
|||||||
esac; \
|
esac; \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
ja:
|
||||||
|
@mkdir -p ./intl/ja
|
||||||
|
@for f in internat.po internat.mo; do \
|
||||||
|
if test ! -f ./intl/ja/$$f -a ! -d ./intl/ja/$$f ; \
|
||||||
|
then x=yep ; \
|
||||||
|
else x=`find $(srcdir)/intl/ja/$$f -newer ./intl/ja/$$f -print` ; \
|
||||||
|
fi; \
|
||||||
|
case "$$x" in ?*) \
|
||||||
|
cp -pRf $(srcdir)/intl/ja/$$f ./intl/ja ;; \
|
||||||
|
esac; \
|
||||||
|
done
|
||||||
|
|
||||||
test_test.o: $(srcdir)/test.cpp $(TEST_ODEP)
|
test_test.o: $(srcdir)/test.cpp $(TEST_ODEP)
|
||||||
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/test.cpp
|
$(CXXC) -c -o $@ $(TEST_CXXFLAGS) $(srcdir)/test.cpp
|
||||||
|
|
||||||
@@ -1075,4 +1087,4 @@ failtest_weakref:
|
|||||||
# Include dependency info, if present:
|
# Include dependency info, if present:
|
||||||
@IF_GNU_MAKE@-include ./.deps/*.d
|
@IF_GNU_MAKE@-include ./.deps/*.d
|
||||||
|
|
||||||
.PHONY: all install uninstall clean distclean test_gui_bundle data data-images fr
|
.PHONY: all install uninstall clean distclean test_gui_bundle data data-images fr ja
|
||||||
|
BIN
tests/intl/ja/internat.mo
Normal file
BIN
tests/intl/ja/internat.mo
Normal file
Binary file not shown.
40
tests/intl/ja/internat.po
Normal file
40
tests/intl/ja/internat.po
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# Message catalog file template for the wxWindows i18n sample
|
||||||
|
# Copyright (C) 1999 wxWindows development team
|
||||||
|
# Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: wxWindows 2.0 i18n sample\n"
|
||||||
|
"POT-Creation-Date: 1999-01-13 18:19+0100\n"
|
||||||
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
|
"Last-Translator: Tadashi Jokagi\n"
|
||||||
|
"Language-Team: Japanese (http://www.transifex.com/projects/p/4Pane/language/ja/)\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
|
msgid "&File"
|
||||||
|
msgstr "ファイル(&F)"
|
||||||
|
|
||||||
|
msgid "E&dit\tCtrl+E"
|
||||||
|
msgstr "編集(&D)\tCtrl+E"
|
||||||
|
|
||||||
|
msgid "Vie&w\tCtrl+V"
|
||||||
|
msgstr "閲覧 (&W)\tCtrl+V"
|
||||||
|
|
||||||
|
msgid "&Options"
|
||||||
|
msgstr "オプション(&O)"
|
||||||
|
|
||||||
|
msgid "&Help"
|
||||||
|
msgstr "ヘルプ(&H)"
|
||||||
|
|
||||||
|
# Supply a non-mnemonic, non-shortcut translation for easier comparison
|
||||||
|
msgid "Edit"
|
||||||
|
msgstr "編集"
|
||||||
|
|
||||||
|
msgid "View"
|
||||||
|
msgstr "閲覧"
|
||||||
|
|
||||||
|
# Nothing to do with Japanese; here to test a translation with a 'normal' mnenomic
|
||||||
|
msgid "B&ogus"
|
||||||
|
msgstr "Preten&d"
|
@@ -462,7 +462,7 @@ $(OBJS):
|
|||||||
|
|
||||||
### Targets: ###
|
### Targets: ###
|
||||||
|
|
||||||
all: $(OBJS)\test.exe $(__test_drawing___depname) $(__test_drawingplugin___depname) $(__test_gui___depname) data data-images fr
|
all: $(OBJS)\test.exe $(__test_drawing___depname) $(__test_drawingplugin___depname) $(__test_gui___depname) data data-images fr ja
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-if exist $(OBJS)\*.obj del $(OBJS)\*.obj
|
-if exist $(OBJS)\*.obj del $(OBJS)\*.obj
|
||||||
@@ -531,6 +531,10 @@ fr:
|
|||||||
if not exist $(OBJS)\intl\fr mkdir $(OBJS)\intl\fr
|
if not exist $(OBJS)\intl\fr mkdir $(OBJS)\intl\fr
|
||||||
for %f in (internat.po internat.mo) do if not exist $(OBJS)\intl\fr\%f copy .\intl\fr\%f $(OBJS)\intl\fr
|
for %f in (internat.po internat.mo) do if not exist $(OBJS)\intl\fr\%f copy .\intl\fr\%f $(OBJS)\intl\fr
|
||||||
|
|
||||||
|
ja:
|
||||||
|
if not exist $(OBJS)\intl\ja mkdir $(OBJS)\intl\ja
|
||||||
|
for %f in (internat.po internat.mo) do if not exist $(OBJS)\intl\ja\%f copy .\intl\ja\%f $(OBJS)\intl\ja
|
||||||
|
|
||||||
$(OBJS)\test_dummy.obj: .\dummy.cpp
|
$(OBJS)\test_dummy.obj: .\dummy.cpp
|
||||||
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) -H .\dummy.cpp
|
$(CXX) -q -c -P -o$@ $(TEST_CXXFLAGS) -H .\dummy.cpp
|
||||||
|
|
||||||
|
@@ -465,7 +465,7 @@ $(OBJS):
|
|||||||
|
|
||||||
### Targets: ###
|
### Targets: ###
|
||||||
|
|
||||||
all: $(OBJS)\test.exe $(__test_drawing___depname) $(__test_drawingplugin___depname) $(__test_gui___depname) data data-images fr
|
all: $(OBJS)\test.exe $(__test_drawing___depname) $(__test_drawingplugin___depname) $(__test_gui___depname) data data-images fr ja
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-if exist $(OBJS)\*.o del $(OBJS)\*.o
|
-if exist $(OBJS)\*.o del $(OBJS)\*.o
|
||||||
@@ -507,6 +507,10 @@ fr:
|
|||||||
if not exist $(OBJS)\intl\fr mkdir $(OBJS)\intl\fr
|
if not exist $(OBJS)\intl\fr mkdir $(OBJS)\intl\fr
|
||||||
for %%f in (internat.po internat.mo) do if not exist $(OBJS)\intl\fr\%%f copy .\intl\fr\%%f $(OBJS)\intl\fr
|
for %%f in (internat.po internat.mo) do if not exist $(OBJS)\intl\fr\%%f copy .\intl\fr\%%f $(OBJS)\intl\fr
|
||||||
|
|
||||||
|
ja:
|
||||||
|
if not exist $(OBJS)\intl\ja mkdir $(OBJS)\intl\ja
|
||||||
|
for %%f in (internat.po internat.mo) do if not exist $(OBJS)\intl\ja\%%f copy .\intl\ja\%%f $(OBJS)\intl\ja
|
||||||
|
|
||||||
$(OBJS)\test_dummy.o: ./dummy.cpp
|
$(OBJS)\test_dummy.o: ./dummy.cpp
|
||||||
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
$(CXX) -c -o $@ $(TEST_CXXFLAGS) $(CPPDEPS) $<
|
||||||
|
|
||||||
@@ -1056,7 +1060,7 @@ $(OBJS)\test_gui_setsize.o: ./window/setsize.cpp
|
|||||||
$(OBJS)\test_gui_xrctest.o: ./xml/xrctest.cpp
|
$(OBJS)\test_gui_xrctest.o: ./xml/xrctest.cpp
|
||||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||||
|
|
||||||
.PHONY: all clean data data-images fr
|
.PHONY: all clean data data-images fr ja
|
||||||
|
|
||||||
|
|
||||||
SHELL := $(COMSPEC)
|
SHELL := $(COMSPEC)
|
||||||
|
@@ -651,7 +651,7 @@ $(OBJS):
|
|||||||
|
|
||||||
### Targets: ###
|
### Targets: ###
|
||||||
|
|
||||||
all: $(OBJS)\test.exe $(__test_drawing___depname) $(__test_drawingplugin___depname) $(__test_gui___depname) data data-images fr
|
all: $(OBJS)\test.exe $(__test_drawing___depname) $(__test_drawingplugin___depname) $(__test_gui___depname) data data-images fr ja
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-if exist $(OBJS)\*.obj del $(OBJS)\*.obj
|
-if exist $(OBJS)\*.obj del $(OBJS)\*.obj
|
||||||
@@ -708,6 +708,10 @@ fr:
|
|||||||
if not exist $(OBJS)\intl\fr mkdir $(OBJS)\intl\fr
|
if not exist $(OBJS)\intl\fr mkdir $(OBJS)\intl\fr
|
||||||
for %f in (internat.po internat.mo) do if not exist $(OBJS)\intl\fr\%f copy .\intl\fr\%f $(OBJS)\intl\fr
|
for %f in (internat.po internat.mo) do if not exist $(OBJS)\intl\fr\%f copy .\intl\fr\%f $(OBJS)\intl\fr
|
||||||
|
|
||||||
|
ja:
|
||||||
|
if not exist $(OBJS)\intl\ja mkdir $(OBJS)\intl\ja
|
||||||
|
for %f in (internat.po internat.mo) do if not exist $(OBJS)\intl\ja\%f copy .\intl\ja\%f $(OBJS)\intl\ja
|
||||||
|
|
||||||
$(OBJS)\test_dummy.obj: .\dummy.cpp
|
$(OBJS)\test_dummy.obj: .\dummy.cpp
|
||||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) /Yctestprec.h .\dummy.cpp
|
$(CXX) /c /nologo /TP /Fo$@ $(TEST_CXXFLAGS) /Yctestprec.h .\dummy.cpp
|
||||||
|
|
||||||
|
@@ -86,6 +86,7 @@ private:
|
|||||||
CPPUNIT_TEST( EnableTop );
|
CPPUNIT_TEST( EnableTop );
|
||||||
CPPUNIT_TEST( Count );
|
CPPUNIT_TEST( Count );
|
||||||
CPPUNIT_TEST( Labels );
|
CPPUNIT_TEST( Labels );
|
||||||
|
CPPUNIT_TEST( i18n );
|
||||||
CPPUNIT_TEST( RadioItems );
|
CPPUNIT_TEST( RadioItems );
|
||||||
CPPUNIT_TEST( RemoveAdd );
|
CPPUNIT_TEST( RemoveAdd );
|
||||||
CPPUNIT_TEST( ChangeBitmap );
|
CPPUNIT_TEST( ChangeBitmap );
|
||||||
@@ -99,6 +100,7 @@ private:
|
|||||||
void EnableTop();
|
void EnableTop();
|
||||||
void Count();
|
void Count();
|
||||||
void Labels();
|
void Labels();
|
||||||
|
void i18n();
|
||||||
void RadioItems();
|
void RadioItems();
|
||||||
void RemoveAdd();
|
void RemoveAdd();
|
||||||
void ChangeBitmap();
|
void ChangeBitmap();
|
||||||
@@ -334,6 +336,36 @@ void MenuTestCase::Labels()
|
|||||||
CPPUNIT_ASSERT_EQUAL( "Foo", wxMenuItem::GetLabelText("&Foo\tCtrl-F") );
|
CPPUNIT_ASSERT_EQUAL( "Foo", wxMenuItem::GetLabelText("&Foo\tCtrl-F") );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuTestCase::i18n()
|
||||||
|
{
|
||||||
|
// Check that appended mnemonics are correctly stripped;
|
||||||
|
// see http://trac.wxwidgets.org/ticket/16736
|
||||||
|
wxLocale::AddCatalogLookupPathPrefix("./intl");
|
||||||
|
CPPUNIT_ASSERT( wxLocale::IsAvailable(wxLANGUAGE_JAPANESE) );
|
||||||
|
|
||||||
|
wxLocale locale(wxLANGUAGE_JAPANESE, wxLOCALE_DONT_LOAD_DEFAULT);
|
||||||
|
locale.AddCatalog("internat");
|
||||||
|
|
||||||
|
// Check the translation is being used:
|
||||||
|
CPPUNIT_ASSERT( wxString("&File") != wxString(_("&File")) );
|
||||||
|
|
||||||
|
wxString filemenu = m_frame->GetMenuBar()->GetMenuLabel(0);
|
||||||
|
CPPUNIT_ASSERT_EQUAL
|
||||||
|
( wxStripMenuCodes(_("&File")),
|
||||||
|
wxStripMenuCodes(wxGetTranslation(filemenu))
|
||||||
|
);
|
||||||
|
|
||||||
|
// Test strings that have shortcuts. Duplicate non-mnemonic translations
|
||||||
|
// exist for both "Edit" and "View", for ease of comparison
|
||||||
|
CPPUNIT_ASSERT_EQUAL( _("Edit"), wxStripMenuCodes(_("E&dit\tCtrl+E")) );
|
||||||
|
|
||||||
|
//"Vie&w" also has a space before the (&W)
|
||||||
|
CPPUNIT_ASSERT_EQUAL( _("View"), wxStripMenuCodes(_("Vie&w\tCtrl+V")) );
|
||||||
|
|
||||||
|
// Test a 'normal' mnemonic too: the translation is "Preten&d"
|
||||||
|
CPPUNIT_ASSERT_EQUAL( "Pretend", wxStripMenuCodes(_("B&ogus")) );
|
||||||
|
}
|
||||||
|
|
||||||
void MenuTestCase::RadioItems()
|
void MenuTestCase::RadioItems()
|
||||||
{
|
{
|
||||||
wxMenuBar * const bar = m_frame->GetMenuBar();
|
wxMenuBar * const bar = m_frame->GetMenuBar();
|
||||||
|
@@ -328,6 +328,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<wx-data id="fr" template="catalog"/>
|
<wx-data id="fr" template="catalog"/>
|
||||||
|
<wx-data id="ja" template="catalog"/>
|
||||||
|
|
||||||
|
|
||||||
<fragment format="autoconf">
|
<fragment format="autoconf">
|
||||||
|
Reference in New Issue
Block a user