mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +02:00
ComponentInterfaceSymbol contains TranslatableString
This commit is contained in:
parent
e4a7c9ba5b
commit
b351eabf47
@ -73,14 +73,15 @@ public:
|
||||
|
||||
// Two-argument version distinguishes internal from translatable string
|
||||
// such as when the first squeezes spaces out
|
||||
ComponentInterfaceSymbol( const wxString &internal, const wxString &msgid )
|
||||
ComponentInterfaceSymbol( const wxString &internal,
|
||||
const TranslatableString &msgid )
|
||||
: mInternal{ internal }
|
||||
// Do not permit non-empty msgid with empty internal
|
||||
, mMsgid{ internal.empty() ? wxString{} : msgid }
|
||||
, mMsgid{ internal.empty() ? TranslatableString{} : msgid }
|
||||
{}
|
||||
|
||||
const wxString &Internal() const { return mInternal; }
|
||||
const wxString &Msgid() const { return mMsgid; }
|
||||
const TranslatableString &Msgid() const { return mMsgid; }
|
||||
const wxString &Translation() const
|
||||
{ return GetCustomTranslation( mMsgid ); }
|
||||
|
||||
@ -96,7 +97,7 @@ public:
|
||||
|
||||
private:
|
||||
wxString mInternal;
|
||||
wxString mMsgid;
|
||||
TranslatableString mMsgid;
|
||||
};
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ private:
|
||||
|
||||
int mNumLangs;
|
||||
wxArrayString mLangCodes;
|
||||
wxArrayStringEx mLangNames;
|
||||
TranslatableStrings mLangNames;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
@ -87,8 +87,11 @@ LangChoiceDialog::LangChoiceDialog(wxWindow * parent,
|
||||
{
|
||||
S.SetBorder(15);
|
||||
mChoice = S.AddChoice(_("Choose Language for Audacity to use:"),
|
||||
mLangNames,
|
||||
lang);
|
||||
transform_container<wxArrayStringEx>(mLangNames,
|
||||
// Using MSGID until AddChoice is rewritten to take
|
||||
// TranslatableStrings directly
|
||||
[](const TranslatableString &str){ return str.MSGID().GET(); }),
|
||||
lang);
|
||||
}
|
||||
S.EndVerticalLay();
|
||||
|
||||
@ -124,7 +127,7 @@ void LangChoiceDialog::OnOk(wxCommandEvent & WXUNUSED(event))
|
||||
/* i18n-hint: The %s's are replaced by translated and untranslated
|
||||
* versions of language names. */
|
||||
msg.Printf(_("The language you have chosen, %s (%s), is not the same as the system language, %s (%s)."),
|
||||
mLangNames[ndx],
|
||||
mLangNames[ndx].Translation(),
|
||||
mLang,
|
||||
sname,
|
||||
slang);
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "Languages.h"
|
||||
#include "MemoryX.h"
|
||||
|
||||
#include "audacity/Types.h"
|
||||
#include "Internat.h"
|
||||
|
||||
#include <wx/defs.h>
|
||||
#include <wx/intl.h>
|
||||
@ -44,7 +44,8 @@
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
using LangHash = std::unordered_map<wxString, wxString>;
|
||||
using LangHash = std::unordered_map<wxString, TranslatableString>;
|
||||
using ReverseLangHash = std::unordered_map<TranslatableString, wxString>;
|
||||
|
||||
static bool TranslationExists(const FilePaths &audacityPathList, wxString code)
|
||||
{
|
||||
@ -76,7 +77,7 @@ static bool TranslationExists(const FilePaths &audacityPathList, wxString code)
|
||||
wxString GetSystemLanguageCode()
|
||||
{
|
||||
wxArrayString langCodes;
|
||||
wxArrayString langNames;
|
||||
TranslatableStrings langNames;
|
||||
|
||||
GetLanguages(langCodes, langNames);
|
||||
|
||||
@ -127,7 +128,8 @@ wxString GetSystemLanguageCode()
|
||||
return wxT("en");
|
||||
}
|
||||
|
||||
void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
|
||||
void GetLanguages(
|
||||
wxArrayString &langCodes, TranslatableStrings &langNames)
|
||||
{
|
||||
static const char *const utf8Names[] = {
|
||||
"af Afrikaans",
|
||||
@ -188,9 +190,9 @@ void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
|
||||
"zh_TW \344\270\255\346\226\207\357\274\210\347\271\201\351\253\224\357\274\211",
|
||||
};
|
||||
|
||||
wxArrayString tempNames;
|
||||
TranslatableStrings tempNames;
|
||||
wxArrayString tempCodes;
|
||||
LangHash reverseHash;
|
||||
ReverseLangHash reverseHash;
|
||||
LangHash tempHash;
|
||||
|
||||
const LangHash localLanguageName = []{
|
||||
@ -200,7 +202,7 @@ void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
|
||||
auto str = wxString::FromUTF8(utf8Name);
|
||||
auto code = str.BeforeFirst(' ');
|
||||
auto name = str.AfterFirst(' ');
|
||||
localLanguageName[code] = name;
|
||||
localLanguageName[code] = TranslatableString{ name };
|
||||
}
|
||||
return localLanguageName;
|
||||
}();
|
||||
@ -228,7 +230,7 @@ void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
|
||||
|
||||
wxString fullCode = info->CanonicalName;
|
||||
wxString code = fullCode.Left(2);
|
||||
wxString name = info->Description;
|
||||
TranslatableString name{ info->Description };
|
||||
|
||||
// Logic: Languages codes are sometimes hierarchical, with a
|
||||
// general language code and then a subheading. For example,
|
||||
@ -275,9 +277,8 @@ void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
|
||||
// JKC: Adding language for simplified audacity.
|
||||
{
|
||||
wxString code;
|
||||
wxString name;
|
||||
code = wxT("en-simple");
|
||||
name = wxT("Simplified");
|
||||
auto name = XO("Simplified");
|
||||
if (TranslationExists(audacityPathList, code) ) {
|
||||
tempCodes.push_back(code);
|
||||
tempNames.push_back(name);
|
||||
@ -295,7 +296,7 @@ void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
|
||||
std::sort( tempNames.begin(), tempNames.end() );
|
||||
|
||||
// Add system language
|
||||
langNames.push_back(wxT("System"));
|
||||
langNames.push_back(XO("System"));
|
||||
langCodes.push_back(wxT("System"));
|
||||
|
||||
for(j=0; j<tempNames.size(); j++) {
|
||||
|
@ -14,7 +14,10 @@
|
||||
class wxArrayString;
|
||||
class wxString;
|
||||
|
||||
void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames);
|
||||
#include "audacity/Types.h"
|
||||
|
||||
void GetLanguages(
|
||||
wxArrayString &langCodes, TranslatableStrings &langNames);
|
||||
|
||||
wxString GetSystemLanguageCode();
|
||||
|
||||
|
@ -242,7 +242,7 @@ void FinishPreferences()
|
||||
//////////
|
||||
EnumValueSymbols::EnumValueSymbols(
|
||||
ByColumns_t,
|
||||
const wxArrayStringEx &msgids,
|
||||
const TranslatableStrings &msgids,
|
||||
wxArrayStringEx internals
|
||||
)
|
||||
: mInternals( std::move( internals ) )
|
||||
|
@ -107,7 +107,7 @@ public:
|
||||
// initializer_list, in the case that each column has exactly two strings)
|
||||
EnumValueSymbols(
|
||||
ByColumns_t,
|
||||
const wxArrayStringEx &msgids, // untranslated!
|
||||
const TranslatableStrings &msgids,
|
||||
wxArrayStringEx internals
|
||||
);
|
||||
|
||||
|
@ -1981,7 +1981,7 @@ wxChoice *ShuttleGuiBase::TieChoice(
|
||||
wxChoice * ShuttleGuiBase::TieNumberAsChoice(
|
||||
const wxString &Prompt,
|
||||
const SettingSpec< int > &Setting,
|
||||
const wxArrayStringEx & Choices,
|
||||
const TranslatableStrings & Choices,
|
||||
const std::vector<int> * pInternalChoices,
|
||||
int iNoMatchSelector)
|
||||
{
|
||||
|
@ -291,7 +291,7 @@ public:
|
||||
virtual wxChoice * TieNumberAsChoice(
|
||||
const wxString &Prompt,
|
||||
const SettingSpec< int > &Setting,
|
||||
const wxArrayStringEx & Choices,
|
||||
const TranslatableStrings & Choices,
|
||||
const std::vector<int> * pInternalChoices = nullptr,
|
||||
int iNoMatchSelector = 0 );
|
||||
|
||||
|
@ -208,7 +208,7 @@ public:
|
||||
wxChoice * TieNumberAsChoice(
|
||||
const wxString &Prompt,
|
||||
const SettingSpec< int > &Setting,
|
||||
const wxArrayStringEx & Choices,
|
||||
const TranslatableStrings & Choices,
|
||||
const std::vector<int> * pInternalChoices, int iNoMatchSelector ) override;
|
||||
|
||||
wxTextCtrl * TieTextBox(
|
||||
@ -273,7 +273,7 @@ wxCheckBox * ShuttleGuiGetDefinition::TieCheckBoxOnRight(
|
||||
wxChoice * ShuttleGuiGetDefinition::TieNumberAsChoice(
|
||||
const wxString &Prompt,
|
||||
const SettingSpec< int > &Setting,
|
||||
const wxArrayStringEx & Choices,
|
||||
const TranslatableStrings & Choices,
|
||||
const std::vector<int> * pInternalChoices, int iNoMatchSelector)
|
||||
{
|
||||
// Come here for controls that present non-exhaustive choices among some
|
||||
|
@ -1573,7 +1573,7 @@ std::vector<EnumValueSymbol> NyquistEffect::ParseChoice(const wxString & text)
|
||||
if (extra.empty())
|
||||
results.push_back( { label } );
|
||||
else
|
||||
results.push_back( { extra, label } );
|
||||
results.push_back( { extra, TranslatableString{ label } } );
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -141,7 +141,7 @@ static const wxChar *FFmpegExportCtrlIDNames[] = {
|
||||
namespace
|
||||
{
|
||||
|
||||
const wxArrayStringEx AC3BitRateNames{
|
||||
const TranslatableStrings AC3BitRateNames{
|
||||
// i18n-hint kbps abbreviates "thousands of bits per second"
|
||||
XO("32 kbps"),
|
||||
XO("40 kbps"),
|
||||
@ -314,7 +314,7 @@ namespace {
|
||||
|
||||
/// Bit Rates supported by libAMR-NB encoder
|
||||
/// Sample Rate is always 8 kHz
|
||||
const wxArrayStringEx AMRNBBitRateNames
|
||||
const TranslatableStrings AMRNBBitRateNames
|
||||
{
|
||||
// i18n-hint kbps abbreviates "thousands of bits per second"
|
||||
XO("4.75 kbps"),
|
||||
@ -409,7 +409,7 @@ const int ExportFFmpegWMAOptions::iWMASampleRates[] =
|
||||
namespace {
|
||||
|
||||
/// Bit Rates supported by WMA encoder. Setting bit rate to other values will not result in different file size.
|
||||
const wxArrayStringEx WMABitRateNames
|
||||
const TranslatableStrings WMABitRateNames
|
||||
{
|
||||
// i18n-hint kbps abbreviates "thousands of bits per second"
|
||||
XO("24 kbps"),
|
||||
@ -1430,7 +1430,7 @@ ApplicableFor ExportFFmpegOptions::apptable[] =
|
||||
namespace {
|
||||
|
||||
/// Prediction order method - names.
|
||||
const wxArrayStringEx PredictionOrderMethodNames {
|
||||
const TranslatableStrings PredictionOrderMethodNames {
|
||||
XO("Estimate"),
|
||||
XO("2-level"),
|
||||
XO("4-level"),
|
||||
|
@ -77,7 +77,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
const wxArrayStringEx BitRateNames {
|
||||
const TranslatableStrings BitRateNames {
|
||||
// i18n-hint kbps abbreviates "thousands of bits per second"
|
||||
XO("16 kbps"),
|
||||
XO("24 kbps"),
|
||||
|
@ -123,7 +123,7 @@ enum : int {
|
||||
PRESET_MEDIUM = 3,
|
||||
};
|
||||
|
||||
static const wxArrayStringEx fixRateNames {
|
||||
static const TranslatableStrings fixRateNames {
|
||||
/* i18n-hint: kbps is the bitrate of the MP3 file, kilobits per second*/
|
||||
XO("320 kbps"),
|
||||
XO("256 kbps"),
|
||||
@ -166,7 +166,7 @@ static const std::vector<int> fixRateValues {
|
||||
8,
|
||||
};
|
||||
|
||||
static const wxArrayStringEx varRateNames {
|
||||
static const TranslatableStrings varRateNames {
|
||||
XO("220-260 kbps (Best Quality)"),
|
||||
XO("200-250 kbps"),
|
||||
XO("170-210 kbps"),
|
||||
@ -179,12 +179,12 @@ static const wxArrayStringEx varRateNames {
|
||||
XO("45-85 kbps (Smaller files)"),
|
||||
};
|
||||
|
||||
static const wxArrayStringEx varModeNames {
|
||||
static const TranslatableStrings varModeNames {
|
||||
XO("Fast"),
|
||||
XO("Standard"),
|
||||
};
|
||||
|
||||
static const wxArrayStringEx setRateNames {
|
||||
static const TranslatableStrings setRateNames {
|
||||
/* i18n-hint: Slightly humorous - as in use an insane precision with MP3.*/
|
||||
XO("Insane, 320 kbps"),
|
||||
XO("Extreme, 220-260 kbps"),
|
||||
@ -192,7 +192,7 @@ static const wxArrayStringEx setRateNames {
|
||||
XO("Medium, 145-185 kbps"),
|
||||
};
|
||||
|
||||
static const wxArrayStringEx setRateNamesShort {
|
||||
static const TranslatableStrings setRateNamesShort {
|
||||
/* i18n-hint: Slightly humorous - as in use an insane precision with MP3.*/
|
||||
XO("Insane"),
|
||||
XO("Extreme"),
|
||||
@ -237,7 +237,7 @@ public:
|
||||
void OnQuality(wxCommandEvent& evt);
|
||||
void OnMono(wxCommandEvent& evt);
|
||||
|
||||
void LoadNames(const wxArrayStringEx &choices);
|
||||
void LoadNames(const TranslatableStrings &choices);
|
||||
|
||||
private:
|
||||
|
||||
@ -328,7 +328,7 @@ void ExportMP3Options::PopulateOrExchange(ShuttleGui & S)
|
||||
bool mono = false;
|
||||
gPrefs->Read(wxT("/FileFormats/MP3ForceMono"), &mono, 0);
|
||||
|
||||
const wxArrayStringEx *choices = nullptr;
|
||||
const TranslatableStrings *choices = nullptr;
|
||||
const std::vector< int > *codes = nullptr;
|
||||
bool enable;
|
||||
int defrate;
|
||||
@ -532,7 +532,7 @@ void ExportMP3Options::OnMono(wxCommandEvent& /*evt*/)
|
||||
gPrefs->Flush();
|
||||
}
|
||||
|
||||
void ExportMP3Options::LoadNames(const wxArrayStringEx &names)
|
||||
void ExportMP3Options::LoadNames(const TranslatableStrings &names)
|
||||
{
|
||||
mRate->Clear();
|
||||
for (const auto &name : names)
|
||||
@ -1883,13 +1883,13 @@ ProgressResult ExportMP3::Export(AudacityProject *project,
|
||||
title.Printf(selectionOnly ?
|
||||
_("Exporting selected audio with %s preset") :
|
||||
_("Exporting the audio with %s preset"),
|
||||
GetCustomTranslation( setRateNamesShort[brate] ) );
|
||||
setRateNamesShort[brate].Translation());
|
||||
}
|
||||
else if (rmode == MODE_VBR) {
|
||||
title.Printf(selectionOnly ?
|
||||
_("Exporting selected audio with VBR quality %s") :
|
||||
_("Exporting the audio with VBR quality %s"),
|
||||
GetCustomTranslation( varRateNames[brate] ) );
|
||||
varRateNames[brate].Translation());
|
||||
}
|
||||
else {
|
||||
title.Printf(selectionOnly ?
|
||||
|
@ -223,6 +223,7 @@ void ExportMultiple::PopulateOrExchange(ShuttleGui& S)
|
||||
wxString name = mProject->GetProjectName();
|
||||
wxString defaultFormat = gPrefs->Read(wxT("/Export/Format"), wxT("WAV"));
|
||||
|
||||
TranslatableStrings visibleFormats;
|
||||
wxArrayStringEx formats;
|
||||
mPluginIndex = -1;
|
||||
mFilterIndex = 0;
|
||||
@ -234,7 +235,12 @@ void ExportMultiple::PopulateOrExchange(ShuttleGui& S)
|
||||
++i;
|
||||
for (int j = 0; j < pPlugin->GetFormatCount(); j++)
|
||||
{
|
||||
formats.push_back(mPlugins[i]->GetUntranslatedDescription(j));
|
||||
auto format = mPlugins[i]->GetUntranslatedDescription(j);
|
||||
visibleFormats.push_back( format );
|
||||
// use MSGID of description as a value too, written into config file
|
||||
// This is questionable. A change in the msgid can make the
|
||||
// preference stored in old config files inapplicable
|
||||
formats.push_back( format.MSGID().GET() );
|
||||
if (mPlugins[i]->GetFormat(j) == defaultFormat) {
|
||||
mPluginIndex = i;
|
||||
mSubFormatIndex = j;
|
||||
@ -276,7 +282,11 @@ void ExportMultiple::PopulateOrExchange(ShuttleGui& S)
|
||||
.TieChoice( _("Format:"),
|
||||
{
|
||||
wxT("/Export/MultipleFormat"),
|
||||
{ ByColumns, formats, formats },
|
||||
{
|
||||
ByColumns,
|
||||
visibleFormats,
|
||||
formats
|
||||
},
|
||||
mFilterIndex
|
||||
}
|
||||
);
|
||||
|
@ -116,7 +116,7 @@ void DevicePrefs::GetNamesAndLabels()
|
||||
if ((info!=NULL)&&(info->maxOutputChannels > 0 || info->maxInputChannels > 0)) {
|
||||
wxString name = wxSafeConvertMB2WX(Pa_GetHostApiInfo(info->hostApi)->name);
|
||||
if ( ! make_iterator_range( mHostNames ).contains( name ) ) {
|
||||
mHostNames.push_back(name);
|
||||
mHostNames.push_back( TranslatableString{ name } );
|
||||
mHostLabels.push_back(name);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class DevicePrefs final : public PrefsPanel
|
||||
void OnHost(wxCommandEvent & e);
|
||||
void OnDevice(wxCommandEvent & e);
|
||||
|
||||
wxArrayStringEx mHostNames;
|
||||
TranslatableStrings mHostNames;
|
||||
wxArrayStringEx mHostLabels;
|
||||
|
||||
wxString mPlayDevice;
|
||||
|
@ -67,7 +67,7 @@ wxString GUIPrefs::HelpPageName()
|
||||
}
|
||||
|
||||
void GUIPrefs::GetRangeChoices(
|
||||
wxArrayStringEx *pChoicesUntranslated,
|
||||
TranslatableStrings *pChoicesUntranslated,
|
||||
wxArrayStringEx *pChoicesTranslated,
|
||||
wxArrayStringEx *pCodes,
|
||||
int *pDefaultRangeIndex
|
||||
@ -86,7 +86,7 @@ void GUIPrefs::GetRangeChoices(
|
||||
if (pCodes)
|
||||
*pCodes = sCodes;
|
||||
|
||||
static const auto sChoices = {
|
||||
static const std::initializer_list<TranslatableString> sChoices = {
|
||||
XO("-36 dB (shallow range for high-amplitude editing)") ,
|
||||
XO("-48 dB (PCM range of 8 bit samples)") ,
|
||||
XO("-60 dB (PCM range of 10 bit samples)") ,
|
||||
|
@ -36,7 +36,7 @@ class GUIPrefs final : public PrefsPanel
|
||||
void PopulateOrExchange(ShuttleGui & S) override;
|
||||
|
||||
static void GetRangeChoices(
|
||||
wxArrayStringEx *pChoicesUntranslated,
|
||||
TranslatableStrings *pChoicesUntranslated,
|
||||
wxArrayStringEx *pChoicesTranslated,
|
||||
wxArrayStringEx *pCodes,
|
||||
int *pDefaultRangeIndex = nullptr
|
||||
@ -58,10 +58,10 @@ class GUIPrefs final : public PrefsPanel
|
||||
void Populate();
|
||||
|
||||
wxArrayStringEx mLangCodes;
|
||||
wxArrayStringEx mLangNames;
|
||||
TranslatableStrings mLangNames;
|
||||
|
||||
wxArrayStringEx mRangeCodes;
|
||||
wxArrayStringEx mRangeChoices;
|
||||
TranslatableStrings mRangeChoices;
|
||||
int mDefaultRangeIndex;
|
||||
};
|
||||
|
||||
|
@ -120,7 +120,7 @@ void MidiIOPrefs::GetNamesAndLabels() {
|
||||
if (info->output || info->input) { //should always happen
|
||||
wxString name = wxSafeConvertMB2WX(info->interf);
|
||||
if ( ! make_iterator_range( mHostNames ).contains( name ) ) {
|
||||
mHostNames.push_back(name);
|
||||
mHostNames.push_back( TranslatableString{ name } );
|
||||
mHostLabels.push_back(name);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class MidiIOPrefs final : public PrefsPanel
|
||||
void OnHost(wxCommandEvent & e);
|
||||
// void OnDevice(wxCommandEvent & e);
|
||||
|
||||
wxArrayStringEx mHostNames;
|
||||
TranslatableStrings mHostNames;
|
||||
wxArrayStringEx mHostLabels;
|
||||
|
||||
wxString mPlayDevice;
|
||||
|
@ -124,7 +124,13 @@ void QualityPrefs::GetNamesAndLabels()
|
||||
for (int i = 0; i < AudioIOBase::NumStandardRates; i++) {
|
||||
int iRate = AudioIOBase::StandardRates[i];
|
||||
mSampleRateLabels.push_back(iRate);
|
||||
mSampleRateNames.push_back(wxString::Format(wxT("%i Hz"), iRate));
|
||||
mSampleRateNames.push_back(
|
||||
// Composing strings for the choice control
|
||||
// Note: the format string is localized, then substituted,
|
||||
// and then the result is treated as if it were a msgid
|
||||
// but really isn't in the translation catalog
|
||||
/* i18n-hint Hertz, a unit of frequency */
|
||||
TranslatableString{ wxString::Format(_("%i Hz"), iRate) } );
|
||||
}
|
||||
|
||||
mSampleRateNames.push_back(XO("Other..."));
|
||||
@ -157,7 +163,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
&mSampleRateLabels,
|
||||
// If the value in Prefs isn't in the list, then we want
|
||||
// the last item, 'Other...' to be shown.
|
||||
mSampleRateNames.GetCount() - 1
|
||||
mSampleRateNames.size() - 1
|
||||
);
|
||||
|
||||
// Now do the edit box...
|
||||
|
@ -46,7 +46,7 @@ class QualityPrefs final : public PrefsPanel
|
||||
void GetNamesAndLabels();
|
||||
void OnSampleRateChoice(wxCommandEvent & e);
|
||||
|
||||
wxArrayStringEx mSampleRateNames;
|
||||
TranslatableStrings mSampleRateNames;
|
||||
std::vector<int> mSampleRateLabels;
|
||||
|
||||
wxChoice *mSampleRates;
|
||||
|
Loading…
x
Reference in New Issue
Block a user