mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-24 16:20:05 +02:00
Strings in Nyquist plug-ins not translated too early...
... So that if you change language in-session, they will update.
This commit is contained in:
parent
f6efacbda3
commit
08a8cc4bcf
@ -94,6 +94,15 @@ enum
|
|||||||
static const wxChar *KEY_Version = wxT("Version");
|
static const wxChar *KEY_Version = wxT("Version");
|
||||||
static const wxChar *KEY_Command = wxT("Command");
|
static const wxChar *KEY_Command = wxT("Command");
|
||||||
|
|
||||||
|
wxArrayString NyqControl::GetTranslatedChoices() const
|
||||||
|
{
|
||||||
|
wxArrayString results;
|
||||||
|
std::transform(
|
||||||
|
choices.begin(), choices.end(), std::back_inserter(results),
|
||||||
|
GetCustomTranslation);
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// NyquistEffect
|
// NyquistEffect
|
||||||
@ -116,7 +125,7 @@ NyquistEffect::NyquistEffect(const wxString &fName)
|
|||||||
{
|
{
|
||||||
mOutputTrack[0] = mOutputTrack[1] = nullptr;
|
mOutputTrack[0] = mOutputTrack[1] = nullptr;
|
||||||
|
|
||||||
mAction = _("Applying Nyquist Effect...");
|
mAction = XO("Applying Nyquist Effect...");
|
||||||
mInputCmd = wxEmptyString;
|
mInputCmd = wxEmptyString;
|
||||||
mCmd = wxEmptyString;
|
mCmd = wxEmptyString;
|
||||||
mIsPrompt = false;
|
mIsPrompt = false;
|
||||||
@ -337,6 +346,7 @@ bool NyquistEffect::DefineParams( ShuttleParams & S )
|
|||||||
}
|
}
|
||||||
else if (ctrl.type == NYQ_CTRL_CHOICE)
|
else if (ctrl.type == NYQ_CTRL_CHOICE)
|
||||||
{
|
{
|
||||||
|
// untranslated
|
||||||
const wxArrayString &choices = ctrl.choices;
|
const wxArrayString &choices = ctrl.choices;
|
||||||
int x=d;
|
int x=d;
|
||||||
//parms.WriteEnum(ctrl.var, (int) d, choices);
|
//parms.WriteEnum(ctrl.var, (int) d, choices);
|
||||||
@ -386,6 +396,7 @@ bool NyquistEffect::GetAutomationParameters(CommandParameters & parms)
|
|||||||
}
|
}
|
||||||
else if (ctrl.type == NYQ_CTRL_CHOICE)
|
else if (ctrl.type == NYQ_CTRL_CHOICE)
|
||||||
{
|
{
|
||||||
|
// untranslated
|
||||||
const wxArrayString &choices = ctrl.choices;
|
const wxArrayString &choices = ctrl.choices;
|
||||||
parms.WriteEnum(ctrl.var, (int) d, choices);
|
parms.WriteEnum(ctrl.var, (int) d, choices);
|
||||||
}
|
}
|
||||||
@ -436,6 +447,7 @@ bool NyquistEffect::SetAutomationParameters(CommandParameters & parms)
|
|||||||
else if (ctrl.type == NYQ_CTRL_CHOICE)
|
else if (ctrl.type == NYQ_CTRL_CHOICE)
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
|
// untranslated
|
||||||
const wxArrayString &choices = ctrl.choices;
|
const wxArrayString &choices = ctrl.choices;
|
||||||
good = parms.ReadEnum(ctrl.var, &val, choices) &&
|
good = parms.ReadEnum(ctrl.var, &val, choices) &&
|
||||||
val != wxNOT_FOUND;
|
val != wxNOT_FOUND;
|
||||||
@ -476,6 +488,7 @@ bool NyquistEffect::SetAutomationParameters(CommandParameters & parms)
|
|||||||
else if (ctrl.type == NYQ_CTRL_CHOICE)
|
else if (ctrl.type == NYQ_CTRL_CHOICE)
|
||||||
{
|
{
|
||||||
int val {0};
|
int val {0};
|
||||||
|
// untranslated
|
||||||
const wxArrayString &choices = ctrl.choices;
|
const wxArrayString &choices = ctrl.choices;
|
||||||
parms.ReadEnum(ctrl.var, &val, choices);
|
parms.ReadEnum(ctrl.var, &val, choices);
|
||||||
ctrl.val = (double) val;
|
ctrl.val = (double) val;
|
||||||
@ -1529,13 +1542,12 @@ void NyquistEffect::Stop()
|
|||||||
mStop = true;
|
mStop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString NyquistEffect::UnQuote(
|
wxString NyquistEffect::UnQuote(const wxString &s, bool allowParens)
|
||||||
const wxString &s, bool allowParens, bool translate)
|
|
||||||
{
|
{
|
||||||
int len = s.Length();
|
int len = s.Length();
|
||||||
if (len >= 2 && s[0] == wxT('\"') && s[len - 1] == wxT('\"')) {
|
if (len >= 2 && s[0] == wxT('\"') && s[len - 1] == wxT('\"')) {
|
||||||
auto unquoted = s.Mid(1, len - 2);
|
auto unquoted = s.Mid(1, len - 2);
|
||||||
return translate ? GetCustomTranslation( unquoted ) : unquoted;
|
return unquoted;
|
||||||
}
|
}
|
||||||
else if (allowParens &&
|
else if (allowParens &&
|
||||||
len >= 2 && s[0] == wxT('(') && s[len - 1] == wxT(')')) {
|
len >= 2 && s[0] == wxT('(') && s[len - 1] == wxT(')')) {
|
||||||
@ -1545,7 +1557,7 @@ wxString NyquistEffect::UnQuote(
|
|||||||
if (tokens.size() > 1)
|
if (tokens.size() > 1)
|
||||||
// Assume the first token was _ -- we don't check that
|
// Assume the first token was _ -- we don't check that
|
||||||
// And the second is the string, which is internationalized
|
// And the second is the string, which is internationalized
|
||||||
return UnQuote( tokens[1], false, true );
|
return UnQuote( tokens[1], false );
|
||||||
else
|
else
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -1809,7 +1821,7 @@ bool NyquistEffect::Parse(
|
|||||||
// Page name in Audacity development manual
|
// Page name in Audacity development manual
|
||||||
if (len >= 2 && tokens[0] == wxT("manpage")) {
|
if (len >= 2 && tokens[0] == wxT("manpage")) {
|
||||||
// do not translate
|
// do not translate
|
||||||
mManPage = UnQuote(tokens[1], false, false);
|
mManPage = UnQuote(tokens[1], false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1817,7 +1829,7 @@ bool NyquistEffect::Parse(
|
|||||||
// Local Help file
|
// Local Help file
|
||||||
if (len >= 2 && tokens[0] == wxT("helpfile")) {
|
if (len >= 2 && tokens[0] == wxT("helpfile")) {
|
||||||
// do not translate
|
// do not translate
|
||||||
mHelpFile = UnQuote(tokens[1], false, false);
|
mHelpFile = UnQuote(tokens[1], false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2229,10 +2241,10 @@ bool NyquistEffect::TransferDataToEffectWindow()
|
|||||||
|
|
||||||
if (ctrl.type == NYQ_CTRL_CHOICE)
|
if (ctrl.type == NYQ_CTRL_CHOICE)
|
||||||
{
|
{
|
||||||
const wxArrayString &choices = ctrl.choices;
|
const auto count = ctrl.choices.GetCount();
|
||||||
|
|
||||||
int val = (int)ctrl.val;
|
int val = (int)ctrl.val;
|
||||||
if (val < 0 || val >= (int)choices.GetCount())
|
if (val < 0 || val >= (int)count)
|
||||||
{
|
{
|
||||||
val = 0;
|
val = 0;
|
||||||
}
|
}
|
||||||
@ -2393,7 +2405,7 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S)
|
|||||||
{
|
{
|
||||||
S.AddSpace(10, 10);
|
S.AddSpace(10, 10);
|
||||||
|
|
||||||
const wxArrayString &choices = ctrl.choices;
|
const wxArrayString &choices = ctrl.GetTranslatedChoices();
|
||||||
S.Id(ID_Choice + i).AddChoice( {}, wxT(""), &choices);
|
S.Id(ID_Choice + i).AddChoice( {}, wxT(""), &choices);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -53,11 +53,13 @@ public:
|
|||||||
//NyqControl( NyqControl && ) = default;
|
//NyqControl( NyqControl && ) = default;
|
||||||
//NyqControl &operator = ( NyqControl && ) = default;
|
//NyqControl &operator = ( NyqControl && ) = default;
|
||||||
|
|
||||||
|
wxArrayString GetTranslatedChoices() const;
|
||||||
|
|
||||||
int type;
|
int type;
|
||||||
wxString var;
|
wxString var;
|
||||||
wxString name;
|
wxString name;
|
||||||
wxString label;
|
wxString label;
|
||||||
wxArrayString choices;
|
wxArrayString choices; // translatable
|
||||||
wxString valStr;
|
wxString valStr;
|
||||||
wxString lowStr;
|
wxString lowStr;
|
||||||
wxString highStr;
|
wxString highStr;
|
||||||
@ -177,8 +179,7 @@ private:
|
|||||||
};
|
};
|
||||||
bool Parse(Tokenizer &tokenizer, const wxString &line, bool eof, bool first);
|
bool Parse(Tokenizer &tokenizer, const wxString &line, bool eof, bool first);
|
||||||
|
|
||||||
static wxString UnQuote(const wxString &s,
|
static wxString UnQuote(const wxString &s, bool allowParens = true);
|
||||||
bool allowParens = true, bool translate = true);
|
|
||||||
double GetCtrlValue(const wxString &s);
|
double GetCtrlValue(const wxString &s);
|
||||||
|
|
||||||
void OnLoad(wxCommandEvent & evt);
|
void OnLoad(wxCommandEvent & evt);
|
||||||
@ -216,8 +217,8 @@ private:
|
|||||||
wxString mInputCmd; // history: exactly what the user typed
|
wxString mInputCmd; // history: exactly what the user typed
|
||||||
wxString mCmd; // the command to be processed
|
wxString mCmd; // the command to be processed
|
||||||
wxString mName; ///< Name of the Effect (untranslated)
|
wxString mName; ///< Name of the Effect (untranslated)
|
||||||
wxString mAction;
|
wxString mAction; // translatable
|
||||||
wxString mInfo;
|
wxString mInfo; // translatable
|
||||||
wxString mAuthor;
|
wxString mAuthor;
|
||||||
wxString mCopyright;
|
wxString mCopyright;
|
||||||
wxString mManPage; // ONLY use if a help page exists in the manual.
|
wxString mManPage; // ONLY use if a help page exists in the manual.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user