Internat doesn't depend on wxCore, ComponentInterface, MemoryX

This commit is contained in:
Paul Licameli 2021-02-11 13:40:25 -05:00
parent 7e697d1d8f
commit d2bdd60e91
4 changed files with 39 additions and 26 deletions

View File

@ -22,9 +22,6 @@ and on Mac OS X for the filesystem.
#include "Internat.h"
#include "MemoryX.h"
#include <wx/log.h>
#include <wx/intl.h>
#include <wx/filename.h>
@ -32,8 +29,6 @@ and on Mac OS X for the filesystem.
#include <locale.h>
#include <math.h> // for pow()
#include "../include/audacity/ComponentInterface.h"
// in order for the static member variables to exist, they must appear here
// (_outside_) the class definition, in order to be allocated some storage.
// Otherwise, you get link errors.
@ -264,20 +259,6 @@ bool Internat::SanitiseFilename(wxString &name, const wxString &sub)
return result;
}
TranslatableStrings Msgids(
const EnumValueSymbol strings[], size_t nStrings)
{
return transform_range<TranslatableStrings>(
strings, strings + nStrings,
std::mem_fn( &EnumValueSymbol::Msgid )
);
}
TranslatableStrings Msgids( const std::vector<EnumValueSymbol> &strings )
{
return Msgids( strings.data(), strings.size() );
}
const wxChar *const TranslatableString::NullContextName = wxT("*");
const TranslatableString::Formatter
@ -316,8 +297,22 @@ TranslatableString &TranslatableString::Strip( unsigned codes ) &
prevFormatter,
str, TranslatableString::DoGetContext( prevFormatter ),
debug );
if ( codes & MenuCodes )
result = wxStripMenuCodes( result );
if ( codes & MenuCodes ) {
// Don't use this, it's in wxCore
// result = wxStripMenuCodes( result );
decltype( result ) temp;
temp.swap(result);
for ( auto iter = temp.begin(), end = temp.end();
iter != end; ++iter ) {
// Stop at trailing hot key name
if ( *iter == '\t' )
break;
// Strip & (unless escaped by another preceding &)
if ( *iter == '&' && ++iter == end )
break;
result.append( 1, *iter );
}
}
if ( codes & Ellipses ) {
if (result.EndsWith(wxT("...")))
result = result.Left( result.length() - 3 );

View File

@ -160,11 +160,6 @@ private:
#define UTF8CTOWX(X) wxString((X), wxConvUTF8)
#define LAT1CTOWX(X) wxString((X), wxConvISO8859_1)
class ComponentInterfaceSymbol;
AUDACITY_DLL_API TranslatableStrings Msgids(
const EnumValueSymbol strings[], size_t nStrings);
AUDACITY_DLL_API TranslatableStrings Msgids( const std::vector<EnumValueSymbol> &strings );
// Whether disambiguationg contexts are supported
// If not, then the program builds and runs, but strings in the catalog with
// contexts will fail to translate

View File

@ -2480,3 +2480,17 @@ void ShuttleGui::SetMinSize( wxWindow *window, const std::vector<int> & items )
SetMinSize( window, strs );
}
*/
TranslatableStrings Msgids(
const EnumValueSymbol strings[], size_t nStrings)
{
return transform_range<TranslatableStrings>(
strings, strings + nStrings,
std::mem_fn( &EnumValueSymbol::Msgid )
);
}
TranslatableStrings Msgids( const std::vector<EnumValueSymbol> &strings )
{
return Msgids( strings.data(), strings.size() );
}

View File

@ -746,4 +746,13 @@ public:
teShuttleMode GetMode() { return mShuttleMode; };
};
class ComponentInterfaceSymbol;
//! Convenience function often useful when adding choice controls
AUDACITY_DLL_API TranslatableStrings Msgids(
const EnumValueSymbol strings[], size_t nStrings);
//! Convenience function often useful when adding choice controls
AUDACITY_DLL_API TranslatableStrings Msgids( const std::vector<EnumValueSymbol> &strings );
#endif