mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-20 17:41:13 +02:00
Define TranslatableString::Strip()
This commit is contained in:
@@ -312,6 +312,37 @@ bool TranslatableString::IsVerbatim() const
|
||||
return DoGetContext( mFormatter ) == NullContextName;
|
||||
}
|
||||
|
||||
TranslatableString &TranslatableString::Strip( unsigned codes ) &
|
||||
{
|
||||
auto prevFormatter = mFormatter;
|
||||
mFormatter = [prevFormatter, codes]
|
||||
( const wxString & str, TranslatableString::Request request ) -> wxString {
|
||||
switch ( request ) {
|
||||
case Request::Context:
|
||||
return TranslatableString::DoGetContext( prevFormatter );
|
||||
case Request::Format:
|
||||
case Request::DebugFormat:
|
||||
default: {
|
||||
bool debug = request == Request::DebugFormat;
|
||||
auto result =
|
||||
TranslatableString::DoSubstitute( prevFormatter, str, debug );
|
||||
if ( codes & MenuCodes )
|
||||
result = wxStripMenuCodes( result );
|
||||
if ( codes & Ellipses ) {
|
||||
if (result.EndsWith(wxT("...")))
|
||||
result = result.Left( result.length() - 3 );
|
||||
// Also check for the single-character Unicode ellipsis
|
||||
else if (result.EndsWith(wxT("\u2026")))
|
||||
result = result.Left( result.length() - 1 );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
wxString TranslatableString::DoGetContext( const Formatter &formatter )
|
||||
{
|
||||
return formatter ? formatter( {}, Request::Context ) : wxString{};
|
||||
|
@@ -2091,7 +2091,7 @@ void ShuttleGuiBase::UpdateSizersCore(bool bPrepend, int Flags, bool prompt)
|
||||
mpWind->SetToolTip( mItem.mToolTip.Translation() );
|
||||
|
||||
if ( !mItem.mName.empty() )
|
||||
mpWind->SetName( wxStripMenuCodes( mItem.mName.Translation() ) );
|
||||
mpWind->SetName( mItem.mName.Strip().Translation() );
|
||||
|
||||
if ( !mItem.mNameSuffix.empty() )
|
||||
mpWind->SetName(
|
||||
|
Reference in New Issue
Block a user