mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	I18N: wx 3.0 back-compat for translations with context, fix #1694
This commit is contained in:
		
							parent
							
								
									78a9e6036a
								
							
						
					
					
						commit
						fde299bf80
					
				
					 2 changed files with 20 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -2,6 +2,10 @@
 | 
			
		|||
#define _(s)    Slic3r::GUI::I18N::translate((s))
 | 
			
		||||
#endif /* _ */
 | 
			
		||||
 | 
			
		||||
#ifndef _CTX
 | 
			
		||||
#define _CTX(s, ctx) Slic3r::GUI::I18N::translate((s), (ctx))
 | 
			
		||||
#endif /* _ */
 | 
			
		||||
 | 
			
		||||
#ifndef L
 | 
			
		||||
// !!! If you needed to translate some wxString,
 | 
			
		||||
// !!! please use _(L(string))
 | 
			
		||||
| 
						 | 
				
			
			@ -21,6 +25,7 @@
 | 
			
		|||
#define slic3r_GUI_I18N_hpp_
 | 
			
		||||
 | 
			
		||||
#include <wx/intl.h>
 | 
			
		||||
#include <wx/version.h>
 | 
			
		||||
 | 
			
		||||
namespace Slic3r { namespace GUI { 
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +34,20 @@ namespace I18N {
 | 
			
		|||
	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::wstring &s) { return wxGetTranslation(s.c_str()); }
 | 
			
		||||
} 
 | 
			
		||||
 | 
			
		||||
#if wxCHECK_VERSION(3, 1, 1)
 | 
			
		||||
	#define _wxGetTranslation_ctx(S, CTX) wxGetTranslation((S), wxEmptyString, (CTX))
 | 
			
		||||
#else
 | 
			
		||||
	#define _wxGetTranslation_ctx(S, CTX) ((void)(CTX), wxGetTranslation((S)))
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	inline wxString translate(const char *s, const char* ctx)         { return _wxGetTranslation_ctx(wxString(s, wxConvUTF8), ctx); }
 | 
			
		||||
	inline wxString translate(const wchar_t *s, const char* ctx)      { return _wxGetTranslation_ctx(s, ctx); }
 | 
			
		||||
	inline wxString translate(const std::string &s, const char* ctx)  { return _wxGetTranslation_ctx(wxString(s.c_str(), wxConvUTF8), ctx); }
 | 
			
		||||
	inline wxString translate(const std::wstring &s, const char* ctx) { return _wxGetTranslation_ctx(s.c_str(), ctx); }
 | 
			
		||||
 | 
			
		||||
#undef _wxGetTranslation_ctx
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Return translated std::string as a wxString
 | 
			
		||||
wxString	L_str(const std::string &str);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -234,7 +234,7 @@ void OptionsGroup::append_line(const Line& line, wxStaticText**	full_Label/* = n
 | 
			
		|||
// 			wxString str_label = _(option.label);
 | 
			
		||||
//!			To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1
 | 
			
		||||
			wxString str_label = (option.label == "Top" || option.label == "Bottom") ?
 | 
			
		||||
								wxGETTEXT_IN_CONTEXT("Layers", wxString(option.label)) :
 | 
			
		||||
								_CTX(option.label, "Layers") :
 | 
			
		||||
								_(option.label);
 | 
			
		||||
			label = new wxStaticText(parent(), wxID_ANY, str_label + ":", wxDefaultPosition, wxDefaultSize);
 | 
			
		||||
			label->SetFont(label_font);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue