New library lib-strings for Identifier and internationalization
This commit is contained in:
parent
70c4898648
commit
45c6190c51
|
@ -4,6 +4,7 @@
|
|||
# that it depends on
|
||||
set( LIBRARIES
|
||||
"lib-string-utils"
|
||||
lib-strings
|
||||
)
|
||||
|
||||
if ( ${_OPT}has_networking )
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#[[
|
||||
String wrapping types and internationalization support.
|
||||
|
||||
Identifier and specializations of TaggedIdentifier generate types of strings
|
||||
used for different internal purposes, not meant for users to see (except
|
||||
sometimes in macro programming), and the types do not implicitly interconvert.
|
||||
|
||||
TranslatableString holds the English msgid of a string meant for a user to see,
|
||||
and can also bind formatting arguments. It can generate a translation later,
|
||||
even if the global choice of locale changes during its lifetime. It does not
|
||||
implicitly interconvert with wxString.
|
||||
|
||||
This library depends only on the wxBase subset of wxWidgets.
|
||||
]]#
|
||||
|
||||
set( SOURCES
|
||||
Identifier.cpp
|
||||
Identifier.h
|
||||
Internat.cpp
|
||||
Internat.h
|
||||
Languages.cpp
|
||||
Languages.h
|
||||
TranslatableString.cpp
|
||||
TranslatableString.h
|
||||
UnusedStrings.h
|
||||
wxArrayStringEx.h
|
||||
wxArrayStringEx.cpp
|
||||
)
|
||||
set( LIBRARIES
|
||||
PRIVATE
|
||||
wxBase
|
||||
)
|
||||
audacity_library( lib-strings "${SOURCES}" "${LIBRARIES}"
|
||||
"" ""
|
||||
)
|
|
@ -18,7 +18,7 @@
|
|||
/*! String manipulations are discouraged, other than splitting and joining on separator characters.
|
||||
Wherever GET is used to fetch the underlying wxString, there should be a comment explaining the need for it.
|
||||
*/
|
||||
class AUDACITY_DLL_API Identifier
|
||||
class STRINGS_API Identifier
|
||||
{
|
||||
public:
|
||||
|
|
@ -42,7 +42,7 @@ wxArrayString Internat::exclude;
|
|||
// This function allows us to replace Audacity by DarkAudacity without peppering
|
||||
// the source code with changes. We split out this step, the customisation, as
|
||||
// it is used on its own (without translation) in the wxTS macro.
|
||||
AUDACITY_DLL_API const wxString& GetCustomSubstitution(const wxString& str2)
|
||||
STRINGS_API const wxString& GetCustomSubstitution(const wxString& str2)
|
||||
{
|
||||
// If contains 'DarkAudacity, already converted.
|
||||
if( str2.Contains( "DarkAudacity" ))
|
||||
|
@ -60,7 +60,7 @@ AUDACITY_DLL_API const wxString& GetCustomSubstitution(const wxString& str2)
|
|||
return wxTranslations::GetUntranslatedString(str3);
|
||||
}
|
||||
#else
|
||||
AUDACITY_DLL_API const wxString& GetCustomSubstitution(const wxString& str1)
|
||||
STRINGS_API const wxString& GetCustomSubstitution(const wxString& str1)
|
||||
{
|
||||
return str1 ;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ AUDACITY_DLL_API const wxString& GetCustomSubstitution(const wxString& str1)
|
|||
|
||||
// In any translated string, we can replace the name 'Audacity' by 'DarkAudacity'
|
||||
// without requiring translators to see extra strings for the two versions.
|
||||
AUDACITY_DLL_API const wxString& GetCustomTranslation(const wxString& str1)
|
||||
STRINGS_API const wxString& GetCustomTranslation(const wxString& str1)
|
||||
{
|
||||
const wxString& str2 = wxGetTranslation( str1 );
|
||||
return GetCustomSubstitution( str2 );
|
|
@ -20,8 +20,8 @@
|
|||
class wxArrayString;
|
||||
class wxArrayStringEx;
|
||||
|
||||
extern AUDACITY_DLL_API const wxString& GetCustomTranslation(const wxString& str1 );
|
||||
extern AUDACITY_DLL_API const wxString& GetCustomSubstitution(const wxString& str1 );
|
||||
extern STRINGS_API const wxString& GetCustomTranslation(const wxString& str1 );
|
||||
extern STRINGS_API const wxString& GetCustomSubstitution(const wxString& str1 );
|
||||
|
||||
// Marks string for substitution only.
|
||||
#define _TS( s ) GetCustomSubstitution( s )
|
||||
|
@ -100,7 +100,7 @@ extern AUDACITY_DLL_API const wxString& GetCustomSubstitution(const wxString& st
|
|||
#define XPC(sing, plur, n, c) \
|
||||
TranslatableString{ wxT(sing), {} }.Context(c).Plural<(n)>( wxT(plur) )
|
||||
|
||||
class AUDACITY_DLL_API Internat
|
||||
class STRINGS_API Internat
|
||||
{
|
||||
public:
|
||||
/** \brief Initialize internationalisation support. Call this once at
|
|
@ -36,6 +36,7 @@
|
|||
#include "wxArrayStringEx.h"
|
||||
|
||||
#include "Internat.h"
|
||||
#include "wxArrayStringEx.h"
|
||||
|
||||
#include <wx/defs.h>
|
||||
#include <wx/dir.h>
|
|
@ -26,33 +26,33 @@ namespace Languages {
|
|||
(like "pt_BR")
|
||||
@param[out] langNames corresponding autonyms of those languages (like "Português")
|
||||
*/
|
||||
AUDACITY_DLL_API
|
||||
STRINGS_API
|
||||
void GetLanguages( FilePaths pathList,
|
||||
wxArrayString &langCodes, TranslatableStrings &langNames);
|
||||
|
||||
/*!
|
||||
@param pathList paths to search for .mo files, grouped into subdirectories for the different languages
|
||||
*/
|
||||
AUDACITY_DLL_API
|
||||
STRINGS_API
|
||||
wxString GetSystemLanguageCode(const FilePaths &pathList);
|
||||
|
||||
/*!
|
||||
@param audacityPathList paths to search for .mo files, grouped into subdirectories for the different languages
|
||||
@param lang a language code; or if empty or "System", then default to system language.
|
||||
@return the language code actually used which is not lang if lang cannot be found. */
|
||||
AUDACITY_DLL_API
|
||||
STRINGS_API
|
||||
wxString SetLang( const FilePaths &audacityPathList, const wxString & lang );
|
||||
|
||||
/*! @return the last language code that was set */
|
||||
AUDACITY_DLL_API
|
||||
STRINGS_API
|
||||
wxString GetLang();
|
||||
|
||||
/*! @return the last language code that was set (minus country code) */
|
||||
AUDACITY_DLL_API
|
||||
STRINGS_API
|
||||
wxString GetLangShort();
|
||||
|
||||
/*! @return a string as from setlocale() */
|
||||
AUDACITY_DLL_API
|
||||
STRINGS_API
|
||||
wxString GetLocaleName();
|
||||
|
||||
}
|
|
@ -29,7 +29,7 @@ class Identifier;
|
|||
|
||||
Implicit conversions to and from wxString are intentionally disabled
|
||||
*/
|
||||
class AUDACITY_DLL_API TranslatableString {
|
||||
class STRINGS_API TranslatableString {
|
||||
enum class Request;
|
||||
template< size_t N > struct PluralTemp;
|
||||
|
|
@ -156,14 +156,10 @@ list( APPEND SOURCES
|
|||
HistoryWindow.cpp
|
||||
HistoryWindow.h
|
||||
HitTestResult.h
|
||||
Identifier.cpp
|
||||
Identifier.h
|
||||
ImageManipulation.cpp
|
||||
ImageManipulation.h
|
||||
InconsistencyException.cpp
|
||||
InconsistencyException.h
|
||||
Internat.cpp
|
||||
Internat.h
|
||||
InterpolateAudio.cpp
|
||||
InterpolateAudio.h
|
||||
KeyboardCapture.cpp
|
||||
|
@ -174,8 +170,6 @@ list( APPEND SOURCES
|
|||
LabelTrack.h
|
||||
LangChoice.cpp
|
||||
LangChoice.h
|
||||
Languages.cpp
|
||||
Languages.h
|
||||
Legacy.cpp
|
||||
Legacy.h
|
||||
LightThemeAsCeeCode.h
|
||||
|
@ -326,13 +320,10 @@ list( APPEND SOURCES
|
|||
TrackPanelResizerCell.h
|
||||
TrackUtilities.cpp
|
||||
TrackUtilities.h
|
||||
TranslatableString.cpp
|
||||
TranslatableString.h
|
||||
UIHandle.cpp
|
||||
UIHandle.h
|
||||
UndoManager.cpp
|
||||
UndoManager.h
|
||||
UnusedStrings.h
|
||||
UserException.cpp
|
||||
UserException.h
|
||||
ViewInfo.cpp
|
||||
|
@ -349,8 +340,6 @@ list( APPEND SOURCES
|
|||
ZoomInfo.cpp
|
||||
ZoomInfo.h
|
||||
float_cast.h
|
||||
wxArrayStringEx.cpp
|
||||
wxArrayStringEx.h
|
||||
wxFileNameWrapper.h
|
||||
|
||||
# Commands
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef __AUDACITY_KEYBOARD__
|
||||
#define __AUDACITY_KEYBOARD__
|
||||
|
||||
#include "../Identifier.h"
|
||||
#include "Identifier.h"
|
||||
#include <wx/defs.h>
|
||||
|
||||
class wxKeyEvent;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <wx/simplebook.h>
|
||||
#include <wx/valgen.h>
|
||||
|
||||
#include "../Internat.h"
|
||||
#include "Internat.h"
|
||||
#include "../Prefs.h"
|
||||
#include "../ProjectFileManager.h"
|
||||
#include "../Shuttle.h"
|
||||
|
|
|
@ -35,7 +35,8 @@ Functions that find and load all LV2 plugins on the system.
|
|||
#include <wx/log.h>
|
||||
#include <wx/string.h>
|
||||
|
||||
#include "../../Internat.h"
|
||||
#include "Internat.h"
|
||||
#include "wxArrayStringEx.h"
|
||||
|
||||
#include "LV2Effect.h"
|
||||
#include "lv2/event/event.h"
|
||||
|
|
|
@ -54,7 +54,7 @@ effects from this one class.
|
|||
#include "../EffectManager.h"
|
||||
#include "../../FileNames.h"
|
||||
#include "../../LabelTrack.h"
|
||||
#include "../../Languages.h"
|
||||
#include "Languages.h"
|
||||
#include "../../NoteTrack.h"
|
||||
#include "../../TimeTrack.h"
|
||||
#include "../../prefs/SpectrogramSettings.h"
|
||||
|
|
|
@ -49,9 +49,9 @@ but little else.
|
|||
|
||||
#include <memory>
|
||||
#include "audacity/Types.h"
|
||||
#include "../Identifier.h"
|
||||
#include "../Internat.h"
|
||||
#include "../wxArrayStringEx.h"
|
||||
#include "Identifier.h"
|
||||
#include "Internat.h"
|
||||
#include "wxArrayStringEx.h"
|
||||
|
||||
class AudacityProject;
|
||||
class ProgressDialog;
|
||||
|
|
|
@ -21,7 +21,7 @@ setting used in debugging batch (aka macros) processing.
|
|||
#include <wx/intl.h>
|
||||
#include <wx/textdlg.h>
|
||||
|
||||
#include "../Languages.h"
|
||||
#include "Languages.h"
|
||||
#include "../Prefs.h"
|
||||
#include "../ShuttleGui.h"
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <wx/choice.h>
|
||||
#include <wx/defs.h>
|
||||
|
||||
#include "../Languages.h"
|
||||
#include "Languages.h"
|
||||
#include "../PluginManager.h"
|
||||
#include "../Prefs.h"
|
||||
#include "../ShuttleGui.h"
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <wx/defs.h>
|
||||
|
||||
#include "../FileNames.h"
|
||||
#include "../Languages.h"
|
||||
#include "Languages.h"
|
||||
#include "../Theme.h"
|
||||
#include "../Prefs.h"
|
||||
#include "../ShuttleGui.h"
|
||||
|
|
|
@ -21,7 +21,6 @@ Paul Licameli
|
|||
#include <algorithm>
|
||||
|
||||
#include "../FFT.h"
|
||||
#include "../Internat.h"
|
||||
#include "../Prefs.h"
|
||||
|
||||
#include <cmath>
|
||||
|
|
|
@ -11,7 +11,6 @@ Paul Licameli
|
|||
#ifndef __AUDACITY_WAVEFORM_SETTINGS__
|
||||
#define __AUDACITY_WAVEFORM_SETTINGS__
|
||||
|
||||
#include "../Internat.h" // for TranslatableStrings
|
||||
#include "../Prefs.h"
|
||||
|
||||
class EnumValueSymbols;
|
||||
|
|
|
@ -8,7 +8,7 @@ Paul Licameli split from class WaveTrack
|
|||
|
||||
**********************************************************************/
|
||||
|
||||
#include "../../../../Internat.h"
|
||||
#include "Internat.h"
|
||||
#include "WaveTrackViewConstants.h"
|
||||
|
||||
// static
|
||||
|
|
|
@ -22,7 +22,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||
#include "../../widgets/Overlay.h" // to inherit
|
||||
#include "../../commands/CommandContext.h"
|
||||
#include "../../commands/CommandManager.h" // for MenuTable
|
||||
#include "../../Identifier.h"
|
||||
#include "Identifier.h"
|
||||
|
||||
class AudacityProject;
|
||||
class TranslatableString;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
**********************************************************************/
|
||||
|
||||
#include "AudacityMessageBox.h"
|
||||
#include "../Internat.h"
|
||||
#include "Internat.h"
|
||||
|
||||
TranslatableString AudacityMessageBoxCaptionStr()
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#define __AUDACITY_MESSAGE_BOX__
|
||||
|
||||
#include <wx/msgdlg.h>
|
||||
#include "../Internat.h"
|
||||
#include "Internat.h"
|
||||
|
||||
extern AUDACITY_DLL_API TranslatableString AudacityMessageBoxCaptionStr();
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <wx/defs.h>
|
||||
#include <wx/menu.h>
|
||||
|
||||
#include "../Internat.h"
|
||||
#include "Internat.h"
|
||||
#include "../Prefs.h"
|
||||
|
||||
#include <mutex>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <wx/weakref.h> // member variable
|
||||
|
||||
#include "Identifier.h"
|
||||
#include "../wxArrayStringEx.h"
|
||||
#include "wxArrayStringEx.h"
|
||||
|
||||
class wxConfigBase;
|
||||
class wxMenu;
|
||||
|
|
|
@ -31,7 +31,7 @@ around to NEW positions.
|
|||
|
||||
#include "../AColor.h"
|
||||
#include "../AllThemeResources.h"
|
||||
#include "../Internat.h"
|
||||
#include "Internat.h"
|
||||
#include "../Theme.h"
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <wx/defs.h>
|
||||
|
||||
#include <wx/chartype.h> // for typedef wxChar
|
||||
#include "../Internat.h" // for TranslatableStrings
|
||||
#include "Internat.h" // for TranslatableStrings
|
||||
class wxString;
|
||||
|
||||
const TranslatableString &DefaultMultiDialogMessage();
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <wx/defs.h>
|
||||
#include <wx/control.h> // to inherit
|
||||
|
||||
#include "../Internat.h"
|
||||
#include "Internat.h"
|
||||
|
||||
// One event type for each type of control. Event is raised when a control
|
||||
// changes its format. Owners of controls of the same type can listen and
|
||||
|
|
|
@ -25,7 +25,7 @@ class wxCommandEvent;
|
|||
#include <wx/menu.h> // to inherit wxMenu
|
||||
#include "../MemoryX.h"
|
||||
|
||||
#include "../Internat.h"
|
||||
#include "Internat.h"
|
||||
#include "../commands/CommandManager.h"
|
||||
|
||||
class PopupMenuHandler;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#endif
|
||||
|
||||
|
||||
#include "../Internat.h"
|
||||
#include "Internat.h"
|
||||
#include <wx/intl.h>
|
||||
|
||||
#include <locale.h> // for setlocale and LC_ALL
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <wx/setup.h> // for wxUSE_* macros
|
||||
|
||||
#include "AudacityMessageBox.h"
|
||||
#include "../Internat.h"
|
||||
#include "Internat.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <wx/panel.h> // to inherit
|
||||
#include <wx/dialog.h> // to inherit
|
||||
|
||||
#include "../Internat.h"
|
||||
#include "Internat.h"
|
||||
|
||||
#include "Identifier.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue