Audacity 3.2.0
|
Holds a msgid for the translation catalog; may also bind format arguments. More...
#include <TranslatableString.h>
Classes | |
struct | PluralTemp |
Public Types | |
enum | StripOptions : unsigned { MenuCodes = 0x1 , Ellipses = 0x2 } |
using | Formatter = std::function< wxString(const wxString &, Request) > |
A multi-purpose function, depending on the enum argument. More... | |
Public Member Functions | |
TranslatableString () | |
TranslatableString (wxString str, Formatter formatter) | |
TranslatableString (const TranslatableString &)=default | |
TranslatableString & | operator= (const TranslatableString &)=default |
TranslatableString (TranslatableString &&str) | |
TranslatableString & | operator= (TranslatableString &&str) |
bool | empty () const |
Identifier | MSGID () const |
MSGID is the English lookup key in the catalog, not necessarily for user's eyes if locale is some other. More... | |
wxString | Translation () const |
wxString | Debug () const |
Format as an English string for debugging logs and developers' eyes, not for end users. More... | |
bool | IsVerbatim () const |
Returns true if context is NullContextFormatter. More... | |
template<typename... Args> | |
TranslatableString & | Format (Args &&...args) & |
Capture variadic format arguments (by copy) when there is no plural. More... | |
template<typename... Args> | |
TranslatableString && | Format (Args &&...args) && |
TranslatableString & | Context (const wxString &context) & |
Choose a non-default and non-null disambiguating context for lookups. More... | |
TranslatableString && | Context (const wxString &context) && |
TranslatableString & | Join (TranslatableString arg, const wxString &separator={}) & |
Append another translatable string. More... | |
TranslatableString && | Join (TranslatableString arg, const wxString &separator={}) && |
TranslatableString & | operator+= (TranslatableString arg) |
template<size_t N> | |
PluralTemp< N > | Plural (const wxString &pluralStr) && |
Implements the XP macro. More... | |
TranslatableString & | Strip (unsigned options=MenuCodes) & |
TranslatableString && | Strip (unsigned options=MenuCodes) && |
TranslatableString | Stripped (unsigned options=MenuCodes) const |
non-mutating, constructs another TranslatableString object More... | |
wxString | StrippedTranslation () const |
Static Public Attributes | |
static const TranslatableString | Inaudible { wxT("\a") } |
A special string value that will have no screen reader pronunciation. More... | |
Private Types | |
enum class | Request { Context , Format , DebugFormat } |
Private Member Functions | |
TranslatableString (wxString str) | |
Construct a TranslatableString that does no translation but passes str verbatim. More... | |
wxString | DoFormat (bool debug) const |
Static Private Member Functions | |
static wxString | DoGetContext (const Formatter &formatter) |
static wxString | DoSubstitute (const Formatter &formatter, const wxString &format, const wxString &context, bool debug) |
static wxString | DoChooseFormat (const Formatter &formatter, const wxString &singular, const wxString &plural, unsigned nn, bool debug) |
template<typename T > | |
static const T & | TranslateArgument (const T &arg, bool) |
template<typename T > | |
static auto | TranslateArgument (const std::reference_wrapper< T > &arg, bool debug) -> decltype(TranslatableString::TranslateArgument(arg.get(), debug)) |
This allows you to wrap arguments of Format in std::cref. More... | |
static wxString | TranslateArgument (const TranslatableString &arg, bool debug) |
Private Attributes | |
wxString | mMsgid |
Formatter | mFormatter |
Static Private Attributes | |
static const Formatter | NullContextFormatter |
static const wxChar *const | NullContextName = wxT("*") |
Friends | |
bool | operator== (const TranslatableString &x, const TranslatableString &y) |
Warning: comparison of msgids only, which is not all of the information! More... | |
bool | operator!= (const TranslatableString &x, const TranslatableString &y) |
TranslatableString | Verbatim (wxString str) |
Require calls to the one-argument constructor to go through this distinct global function name. More... | |
Holds a msgid for the translation catalog; may also bind format arguments.
Different string-valued accessors for the msgid itself, and for the user-visible translation with substitution of captured format arguments. Also an accessor for format substitution into the English msgid, for debug- only outputs. The msgid should be used only in unusual cases and the translation more often
Implicit conversions to and from wxString are intentionally disabled
Definition at line 32 of file TranslatableString.h.
using TranslatableString::Formatter = std::function< wxString(const wxString &, Request) > |
A multi-purpose function, depending on the enum argument.
the string argument is unused in some cases If there is no function, defaults are empty context string, no plurals, and no substitutions
Definition at line 45 of file TranslatableString.h.
|
strongprivate |
Enumerator | |
---|---|
Context | return a disambiguating context string |
Format | Given the msgid, format the string for end users. |
DebugFormat | Given the msgid, format the string for developers. |
Definition at line 215 of file TranslatableString.h.
enum TranslatableString::StripOptions : unsigned |
Translated strings may still contain menu hot-key codes (indicated by &) that wxWidgets interprets, and also trailing ellipses, that should be removed for other uses.
Enumerator | |
---|---|
MenuCodes | |
Ellipses |
Definition at line 188 of file TranslatableString.h.
|
inline |
Definition at line 47 of file TranslatableString.h.
|
inlineexplicit |
Supply {} for the second argument to cause lookup of the msgid with empty context string (default context) rather than the null context
Definition at line 51 of file TranslatableString.h.
References str.
|
default |
|
inline |
Definition at line 60 of file TranslatableString.h.
References str.
|
inlineexplicitprivate |
Construct a TranslatableString that does no translation but passes str verbatim.
Definition at line 207 of file TranslatableString.h.
References str.
|
inline |
Choose a non-default and non-null disambiguating context for lookups.
This is meant to be the first of chain-call modifications of the TranslatableString object; it will destroy any previously captured information
Definition at line 137 of file TranslatableString.h.
References str.
|
inline |
Definition at line 153 of file TranslatableString.h.
|
inline |
Format as an English string for debugging logs and developers' eyes, not for end users.
Definition at line 82 of file TranslatableString.h.
Referenced by CommandManager::Populator::NewIdentifier(), XMLFileReader::ParseBuffer(), Sequence::Paste(), AUPImportFileHandle::SetError(), and AUPImportFileHandle::SetWarning().
|
staticprivate |
Definition at line 103 of file TranslatableString.cpp.
References DoGetContext(), HAS_I18N_CONTEXTS, and NullContextName.
Referenced by TranslatableString::PluralTemp< N >::operator()().
|
inlineprivate |
Definition at line 228 of file TranslatableString.h.
Referenced by TranslateArgument().
|
staticprivate |
Definition at line 89 of file TranslatableString.cpp.
References Context.
Referenced by DoChooseFormat(), Format(), IsVerbatim(), Join(), TranslatableString::PluralTemp< N >::operator()(), and Strip().
|
staticprivate |
Definition at line 94 of file TranslatableString.cpp.
References DebugFormat, Format, and anonymous_namespace{ExportPCM.cpp}::format.
Referenced by Format(), Join(), and Strip().
|
inline |
Definition at line 72 of file TranslatableString.h.
Referenced by anonymous_namespace{MenuHelper.cpp}::AddGroupedEffectMenuItems(), ShuttleGuiBase::AddPrompt(), anonymous_namespace{MenuHelper.cpp}::AddSortedEffectMenuItems(), ShuttleGuiBase::AddTitle(), ShuttleGuiBase::AddUnits(), BatchEvalCommand::Apply(), PluginDataModel::ApplyChanges(), ShuttleGuiBase::ApplyItem(), anonymous_namespace{ClipMenus.cpp}::ClipBoundaryMessage(), MessageBoxException::DelayedHandlerAction(), CommandManager::DescribeCommandsAndShortcuts(), ProjectFileManager::DoImport(), EffectUIServices::DoMessageBox(), EQUtils::DoMessageBox(), anonymous_namespace{ClipMenus.cpp}::DoSelectClip(), anonymous_namespace{ProjectFileManager.cpp}::FindHelpUrl(), PopupSubMenu::GetProperties(), LWSlider::GetTip(), LWSlider::GetWidestTips(), CellularPanel::HandleMotion(), Importer::Import(), AUPImportFileHandle::Import(), audacity::cloud::audiocom::sync::LinkAccountDialog::LinkAccountDialog(), MP3Exporter::LoadLibrary(), AudacityCommand::MessageBox(), MessageBoxException::MessageBoxException(), EffectUIHost::OnMenu(), anonymous_namespace{PopupMenuTable.cpp}::PopupMenuBuilder::PopupMenuBuilder(), SelectHandle::Preview(), NyquistBase::ProcessOne(), DBConnection::SetDBError(), AUPImportFileHandle::SetError(), DBConnection::SetError(), ProgressDialog::SetMessage(), EffectPresetsDialog::SetPrefix(), SetupAccessibility(), AUPImportFileHandle::SetWarning(), ShuttleGuiBase::StartStatic(), NumericConverter::UpdateFormatter(), RealtimeEffectStateUI::UpdateTitle(), and EffectPresetsDialog::UpdateUI().
|
inline |
Capture variadic format arguments (by copy) when there is no plural.
The substitution is computed later in a call to Translate() after msgid is looked up in the translation catalog. Any format arguments that are also of type TranslatableString will be translated too at substitution time, for non-debug formatting
Definition at line 103 of file TranslatableString.h.
References DoGetContext(), DoSubstitute(), str, and TranslateArgument().
Referenced by EqualizationBandSliders::AddBandSliders(), CommandManager::DescribeCommandsAndShortcuts(), TrackUtilities::DoMoveTrack(), anonymous_namespace{Contrast.cpp}::FormatRMSMessage(), CommandManager::GetPrefixedLabelFromName(), LWSlider::GetTip(), ThemeBase::LoadOneThemeComponents(), KeyConfigPrefs::OnSet(), PitchName_Absolute(), AboutDialog::PopulateInformationPage(), EffectScienFilter::PopulateOrExchange(), NyquistBase::Process(), ControlToolBar::StateForStatusBar(), and VelocitySliderHandle::Tip().
|
inline |
Definition at line 128 of file TranslatableString.h.
bool TranslatableString::IsVerbatim | ( | ) | const |
Returns true if context is NullContextFormatter.
Definition at line 36 of file TranslatableString.cpp.
References DoGetContext(), mFormatter, and NullContextName.
TranslatableString & TranslatableString::Join | ( | TranslatableString | arg, |
const wxString & | separator = {} |
||
) | & |
Append another translatable string.
lookup of msgids for this and for the argument are both delayed until Translate() is invoked on this, and then the formatter concatenates the translations
Definition at line 124 of file TranslatableString.cpp.
References DoGetContext(), DoSubstitute(), and str.
Referenced by MacroCommandsCatalog::MacroCommandsCatalog(), SelectHandle::Preview(), PrefsDialog::ShowModal(), and TrackPanel::UpdateStatusMessage().
|
inline |
Definition at line 164 of file TranslatableString.h.
Identifier TranslatableString::MSGID | ( | ) | const |
MSGID is the English lookup key in the catalog, not necessarily for user's eyes if locale is some other.
The MSGID might not be all the information TranslatableString holds. This is a deliberately ugly-looking function name. Use with caution.
Definition at line 17 of file TranslatableString.cpp.
References mMsgid.
Referenced by anonymous_namespace{ProjectFileManager.cpp}::FindHelpUrl(), CommandManager::Populator::NewIdentifier(), and AudioUnitEffectOptionsDialog::OnOk().
|
inline |
Definition at line 168 of file TranslatableString.h.
References Join().
|
default |
|
inline |
|
inline |
Implements the XP macro.
That macro specifies a second msgid, a list of format arguments, and which of those format arguments selects among messages; the translated strings to select among, depending on language, might actually be more or fewer than two. See Internat.h.
Definition at line 180 of file TranslatableString.h.
TranslatableString & TranslatableString::Strip | ( | unsigned | options = MenuCodes | ) | & |
Definition at line 41 of file TranslatableString.cpp.
References DoGetContext(), DoSubstitute(), details::end(), str, and wxT().
Referenced by MacroCommandsCatalog::MacroCommandsCatalog(), KeyView::RefreshBindings(), and Stripped().
|
inline |
Definition at line 194 of file TranslatableString.h.
|
inline |
non-mutating, constructs another TranslatableString object
Definition at line 198 of file TranslatableString.h.
References Strip().
Referenced by ShuttleGuiBase::AddCheckBoxOnRight(), ShuttleGuiBase::AddChoice(), BatchEvalCommand::Apply(), ShuttleGuiBase::ApplyItem(), MacroCommands::ApplyMacro(), CommandManager::GetPrefixedLabelFromName(), CommandManager::Populator::NewIdentifier(), ControlToolBar::Populate(), SnappingToolBar::Populate(), AButton::SetLabel(), wxPanelWrapper::SetToolTip(), AButton::SetToolTip(), Grabber::SetToolTip(), AdornedRulerPanel::ShowMenu(), and ComponentInterfaceSymbol::Stripped().
|
inline |
Definition at line 201 of file TranslatableString.h.
Referenced by ShuttleGuiBase::AddChoice(), and ShuttleGui::SetMinSize().
|
inlinestaticprivate |
This allows you to wrap arguments of Format in std::cref.
(So that they are captured (as if) by reference rather than by value)
Definition at line 240 of file TranslatableString.h.
References TranslateArgument().
|
inlinestaticprivate |
Definition at line 236 of file TranslatableString.h.
Referenced by Format(), TranslatableString::PluralTemp< N >::operator()(), and TranslateArgument().
|
inlinestaticprivate |
Definition at line 245 of file TranslatableString.h.
References DoFormat().
|
inline |
Definition at line 79 of file TranslatableString.h.
Referenced by ShuttleGuiBase::AddButton(), audacity::cloud::audiocom::sync::AudioComDialogBase::AddButton(), ShuttleGuiBase::AddCheckBox(), ShuttleGuiBase::AddCheckBoxOnRight(), ShuttleGuiBase::AddChoice(), ShuttleGuiBase::AddCombo(), ShuttleGuiBase::AddConstTextBox(), ShuttleGuiBase::AddFixedText(), ShuttleGuiBase::AddNumericTextBox(), audacity::cloud::audiocom::sync::AudioComDialogBase::AddParagraph(), ShuttleGuiBase::AddPrompt(), ShuttleGuiBase::AddReadOnlyText(), ShuttleGuiBase::AddSlider(), ShuttleGuiBase::AddSpinControl(), ShuttleGuiBase::AddSpinCtrl(), ShuttleGuiBase::AddTextBox(), ShuttleGuiBase::AddTitle(), ShuttleGuiBase::AddUnits(), ShuttleGuiBase::AddVariableText(), MacroCommands::ApplyCommand(), ShuttleGuiBase::ApplyItem(), AudacityMessageBox(), LV2Editor::BuildPlain(), ProgressDialog::Create(), FileDialogWrapper::Create(), audacity::cloud::audiocom::sync::anonymous_namespace{CloudLocationDialog.cpp}::CreateButton(), ShuttleGuiBase::DoAddRadioButton(), HistoryDialog::DoUpdate(), CommandManager::CommandListEntry::FormatLabelForMenu(), DistortionBase::GetFactoryPresets(), EqualizationBase::GetFactoryPresets(), ReverbBase::GetFactoryPresets(), anonymous_namespace{SnappingToolBar.cpp}::SnapModePopup::GetStringValue(), audacity::cloud::audiocom::sync::CloudSyncStatusField::StatusWidget::GetText(), NyquistBase::GetVersion(), CellularPanel::HandleMotion(), ImportStreamDialog::ImportStreamDialog(), MacroCommandsCatalog::MacroCommandsCatalog(), audacity::cloud::audiocom::sync::MakeClientFailure(), TrackPanelAx::MessageForScreenReader(), MultiDialog::MultiDialog(), TimerRecordDialog::NewPathControl(), DependencyDialog::OnCopyToClipboard(), LinkingHtmlWindow::OnLinkClicked(), TipWindow::OnPaint(), anonymous_namespace{SnappingToolBar.cpp}::SnapModePopup::OnPopup(), DirectoriesPrefs::OnTempText(), FrequencyPlotDialog::PlotPaint(), SnappingToolBar::Populate(), TranscriptionToolBar::Populate(), AccessibleLinksFormatter::Populate(), LabelDialog::PopulateLabels(), DependencyDialog::PopulateList(), TagsEditorDialog::PopulateOrExchange(), LV2Effect::PopulateUI(), anonymous_namespace{PopupMenuTable.cpp}::PopupMenuBuilder::PopupMenuBuilder(), NyquistBase::Process(), NyquistBase::ProcessOne(), UndoManager::PushState(), anonymous_namespace{RealtimeEffectPanel.cpp}::RealtimeEffectsMenuVisitor::RealtimeEffectsMenuVisitor(), KeyView::RefreshBindings(), SelectFile(), Importer::SetDefaultOpenType(), wxPanelWrapper::SetLabel(), AButton::SetLabel(), wxDialogWrapper::SetLabel(), Importer::SetLastOpenType(), ProgressDialog::SetMessage(), EffectPresetsDialog::SetPrefix(), ProjectManager::SetStatusText(), ProjectStatus::ProjectStatusTextField::SetText(), wxPanelWrapper::SetToolTip(), AButton::SetToolTip(), Grabber::SetToolTip(), ReadOnlyText::SetValue(), AdornedRulerPanel::ShowMenu(), anonymous_namespace{SnappingToolBar.cpp}::SnapModePopup::SnapModePopup(), ShuttleGuiBase::StartStatic(), anonymous_namespace{GetInfoCommand.cpp}::ShuttleGuiGetDefinition::TieCheckBox(), anonymous_namespace{GetInfoCommand.cpp}::ShuttleGuiGetDefinition::TieCheckBoxOnRight(), anonymous_namespace{GetInfoCommand.cpp}::ShuttleGuiGetDefinition::TieChoice(), anonymous_namespace{GetInfoCommand.cpp}::ShuttleGuiGetDefinition::TieIntegerTextBox(), anonymous_namespace{GetInfoCommand.cpp}::ShuttleGuiGetDefinition::TieNumberAsChoice(), anonymous_namespace{GetInfoCommand.cpp}::ShuttleGuiGetDefinition::TieNumericTextBox(), anonymous_namespace{GetInfoCommand.cpp}::ShuttleGuiGetDefinition::TieSlider(), anonymous_namespace{GetInfoCommand.cpp}::ShuttleGuiGetDefinition::TieSpinCtrl(), anonymous_namespace{GetInfoCommand.cpp}::ShuttleGuiGetDefinition::TieTextBox(), TipWindow::TipWindow(), TagsEditorDialog::TransferDataToWindow(), TranslationLess(), NyquistBase::UnQuote(), PluginDataModel::UpdateFilter(), and EffectLegacyCompressor::UpdateUI().
|
friend |
Definition at line 90 of file TranslatableString.h.
|
friend |
Warning: comparison of msgids only, which is not all of the information!
This operator makes it easier to define a std::unordered_map on TranslatableStrings
Definition at line 86 of file TranslatableString.h.
|
friend |
Require calls to the one-argument constructor to go through this distinct global function name.
This makes it easier to locate and review the uses of this function, separately from the uses of the type.
Definition at line 321 of file TranslatableString.h.
|
static |
A special string value that will have no screen reader pronunciation.
Definition at line 38 of file TranslatableString.h.
Referenced by EffectPanel::EffectPanel().
|
private |
Definition at line 286 of file TranslatableString.h.
Referenced by IsVerbatim(), and TranslatableString::PluralTemp< N >::operator()().
|
private |
Definition at line 285 of file TranslatableString.h.
Referenced by MSGID().
|
staticprivate |
Definition at line 204 of file TranslatableString.h.
|
staticprivate |
Definition at line 221 of file TranslatableString.h.
Referenced by DoChooseFormat(), and IsVerbatim().