Plurals for number of Undo / Redo actions.
This commit is contained in:
parent
2b7a4973a8
commit
8865c4b685
@ -368,7 +368,7 @@ target_include_directories(cereal INTERFACE include)
|
|||||||
# l10n
|
# l10n
|
||||||
set(L10N_DIR "${SLIC3R_RESOURCES_DIR}/localization")
|
set(L10N_DIR "${SLIC3R_RESOURCES_DIR}/localization")
|
||||||
add_custom_target(pot
|
add_custom_target(pot
|
||||||
COMMAND xgettext --keyword=L --keyword=L_CONTEXT:1,2c --add-comments=TRN --from-code=UTF-8 --debug
|
COMMAND xgettext --keyword=L --keyword=L_CONTEXT:1,2c --keyword=_L_PLURAL:1,2 --add-comments=TRN --from-code=UTF-8 --debug
|
||||||
-f "${L10N_DIR}/list.txt"
|
-f "${L10N_DIR}/list.txt"
|
||||||
-o "${L10N_DIR}/PrusaSlicer.pot"
|
-o "${L10N_DIR}/PrusaSlicer.pot"
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2019-08-28 15:34+0200\n"
|
"POT-Creation-Date: 2019-08-28 16:09+0200\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -16,6 +16,7 @@ msgstr ""
|
|||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
||||||
|
|
||||||
#: src/slic3r/GUI/AboutDialog.cpp:39 src/slic3r/GUI/AboutDialog.cpp:291
|
#: src/slic3r/GUI/AboutDialog.cpp:39 src/slic3r/GUI/AboutDialog.cpp:291
|
||||||
msgid "Portions copyright"
|
msgid "Portions copyright"
|
||||||
@ -831,23 +832,17 @@ msgstr ""
|
|||||||
|
|
||||||
#: src/slic3r/GUI/GLCanvas3D.cpp:3497
|
#: src/slic3r/GUI/GLCanvas3D.cpp:3497
|
||||||
#, possible-c-format
|
#, possible-c-format
|
||||||
msgid "Undo %d Actions"
|
msgid "Undo %1$d Action"
|
||||||
msgstr ""
|
msgid_plural "Undo %1$d Actions"
|
||||||
|
msgstr[0] ""
|
||||||
|
msgstr[1] ""
|
||||||
|
|
||||||
#: src/slic3r/GUI/GLCanvas3D.cpp:3497
|
#: src/slic3r/GUI/GLCanvas3D.cpp:3497
|
||||||
#, possible-c-format
|
#, possible-c-format
|
||||||
msgid "Redo %d Actions"
|
msgid "Redo %1$d Action"
|
||||||
msgstr ""
|
msgid_plural "Redo %1$d Actions"
|
||||||
|
msgstr[0] ""
|
||||||
#: src/slic3r/GUI/GLCanvas3D.cpp:3497
|
msgstr[1] ""
|
||||||
#, possible-c-format
|
|
||||||
msgid "Undo %d Action"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/slic3r/GUI/GLCanvas3D.cpp:3497
|
|
||||||
#, possible-c-format
|
|
||||||
msgid "Redo %d Action"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: src/slic3r/GUI/GLCanvas3D.cpp:3544
|
#: src/slic3r/GUI/GLCanvas3D.cpp:3544
|
||||||
msgid "Add..."
|
msgid "Add..."
|
||||||
|
@ -3494,7 +3494,7 @@ void GLCanvas3D::_render_undo_redo_stack(const bool is_undo, float pos_x)
|
|||||||
if (selected >= 0)
|
if (selected >= 0)
|
||||||
is_undo ? wxGetApp().plater()->undo_to(selected) : wxGetApp().plater()->redo_to(selected);
|
is_undo ? wxGetApp().plater()->undo_to(selected) : wxGetApp().plater()->redo_to(selected);
|
||||||
|
|
||||||
imgui->text(wxString::Format(_(hovered ? (is_undo ? L("Undo %d Actions") : L("Redo %d Actions")) : (is_undo ? L("Undo %d Action") : L("Redo %d Action"))), hovered + 1));
|
imgui->text(wxString::Format(is_undo ? _L_PLURAL("Undo %1$d Action", "Undo %1$d Actions", hovered + 1) : _L_PLURAL("Redo %1$d Action", "Redo %1$d Actions", hovered + 1), hovered + 1));
|
||||||
|
|
||||||
imgui->end();
|
imgui->end();
|
||||||
}
|
}
|
||||||
|
@ -36,16 +36,26 @@
|
|||||||
namespace Slic3r { namespace GUI {
|
namespace Slic3r { namespace GUI {
|
||||||
|
|
||||||
namespace I18N {
|
namespace I18N {
|
||||||
inline wxString translate(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)); }
|
inline wxString translate(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)); }
|
||||||
inline wxString translate(const wchar_t *s) { return wxGetTranslation(s); }
|
inline wxString translate(const wchar_t *s) { return wxGetTranslation(s); }
|
||||||
inline wxString translate(const std::string &s) { return wxGetTranslation(wxString(s.c_str(), wxConvUTF8)); }
|
inline wxString translate(const std::string &s) { return wxGetTranslation(wxString(s.c_str(), wxConvUTF8)); }
|
||||||
inline wxString translate(const std::wstring &s) { return wxGetTranslation(s.c_str()); }
|
inline wxString translate(const std::wstring &s) { return wxGetTranslation(s.c_str()); }
|
||||||
|
|
||||||
inline std::string translate_utf8(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)).ToUTF8().data(); }
|
inline wxString translate(const char *s, const char *plural, unsigned int n) { return wxGetTranslation(wxString(s, wxConvUTF8), wxString(plural, wxConvUTF8), n); }
|
||||||
inline std::string translate_utf8(const wchar_t *s) { return wxGetTranslation(s).ToUTF8().data(); }
|
inline wxString translate(const wchar_t *s, const wchar_t *plural, unsigned int n) { return wxGetTranslation(s, plural, n); }
|
||||||
inline std::string translate_utf8(const std::string &s) { return wxGetTranslation(wxString(s.c_str(), wxConvUTF8)).ToUTF8().data(); }
|
inline wxString translate(const std::string &s, const std::string &plural, unsigned int n) { return wxGetTranslation(wxString(s.c_str(), wxConvUTF8), wxString(plural.c_str(), wxConvUTF8), n); }
|
||||||
|
inline wxString translate(const std::wstring &s, const std::wstring &plural, unsigned int n) { return wxGetTranslation(s.c_str(), plural.c_str(), n); }
|
||||||
|
|
||||||
|
inline std::string translate_utf8(const char *s) { return wxGetTranslation(wxString(s, wxConvUTF8)).ToUTF8().data(); }
|
||||||
|
inline std::string translate_utf8(const wchar_t *s) { return wxGetTranslation(s).ToUTF8().data(); }
|
||||||
|
inline std::string translate_utf8(const std::string &s) { return wxGetTranslation(wxString(s.c_str(), wxConvUTF8)).ToUTF8().data(); }
|
||||||
inline std::string translate_utf8(const std::wstring &s) { return wxGetTranslation(s.c_str()).ToUTF8().data(); }
|
inline std::string translate_utf8(const std::wstring &s) { return wxGetTranslation(s.c_str()).ToUTF8().data(); }
|
||||||
|
|
||||||
|
inline std::string translate_utf8(const char *s, const char *plural, unsigned int n) { return translate(s, plural, n).ToUTF8().data(); }
|
||||||
|
inline std::string translate_utf8(const wchar_t *s, const wchar_t *plural, unsigned int n) { return translate(s, plural, n).ToUTF8().data(); }
|
||||||
|
inline std::string translate_utf8(const std::string &s, const std::string &plural, unsigned int n) { return translate(s, plural, n).ToUTF8().data(); }
|
||||||
|
inline std::string translate_utf8(const std::wstring &s, const std::wstring &plural, unsigned int n) { return translate(s, plural, n).ToUTF8().data(); }
|
||||||
|
|
||||||
#if wxCHECK_VERSION(3, 1, 1)
|
#if wxCHECK_VERSION(3, 1, 1)
|
||||||
#define _wxGetTranslation_ctx(S, CTX) wxGetTranslation((S), wxEmptyString, (CTX))
|
#define _wxGetTranslation_ctx(S, CTX) wxGetTranslation((S), wxEmptyString, (CTX))
|
||||||
#else
|
#else
|
||||||
@ -63,11 +73,17 @@ namespace I18N {
|
|||||||
inline wxString translate_utf8(const std::wstring &s, const char* ctx) { return _wxGetTranslation_ctx(s.c_str(), ctx).ToUTF8().data(); }
|
inline wxString translate_utf8(const std::wstring &s, const char* ctx) { return _wxGetTranslation_ctx(s.c_str(), ctx).ToUTF8().data(); }
|
||||||
|
|
||||||
#undef _wxGetTranslation_ctx
|
#undef _wxGetTranslation_ctx
|
||||||
}
|
} // namespace I18N
|
||||||
|
|
||||||
// Return translated std::string as a wxString
|
// Return translated std::string as a wxString
|
||||||
wxString L_str(const std::string &str);
|
wxString L_str(const std::string &str);
|
||||||
|
|
||||||
} }
|
} // namespace GUI
|
||||||
|
} // namespace Slic3r
|
||||||
|
|
||||||
|
// Macro to function both as a marker for xgettext and to actually perform the translation.
|
||||||
|
#ifndef _L_PLURAL
|
||||||
|
#define _L_PLURAL(s, plural, n) Slic3r::GUI::I18N::translate(s, plural, n)
|
||||||
|
#endif /* L */
|
||||||
|
|
||||||
#endif /* slic3r_GUI_I18N_hpp_ */
|
#endif /* slic3r_GUI_I18N_hpp_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user