fix: 弹窗提示实时翻译 - PromptWindowInitData新增key+args构造函数, SetFormatted保留原始key供语言切换时重新翻译
This commit is contained in:
parent
53de0cb412
commit
d3d2d765de
@ -80,7 +80,7 @@ public class Subject1EditorCtrl : SubjectEditorBase
|
|||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
Push(new PromptWindows()).Change(new PromptWindowInitData(LocalizationManager.Format("想定文件生成成功!文件路径为:{0}", path), null));
|
Push(new PromptWindows()).Change(new PromptWindowInitData("想定文件生成成功!文件路径为:{0}", new object[] { path }, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -165,7 +165,7 @@ public class Subject2EditorCtrl : SubjectEditorBase
|
|||||||
bool result= XmlHelper.SerializeObjectXML(recordClass, typeof(Sub2RecordClass), path);
|
bool result= XmlHelper.SerializeObjectXML(recordClass, typeof(Sub2RecordClass), path);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
Push(new PromptWindows()).Change(new PromptWindowInitData(LocalizationManager.Format("想定文件生成成功!文件路径为:{0}", path), null));
|
Push(new PromptWindows()).Change(new PromptWindowInitData("想定文件生成成功!文件路径为:{0}", new object[] { path }, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,13 +31,22 @@ public class PromptWindows : BasePanel
|
|||||||
public override void Change(object newData)
|
public override void Change(object newData)
|
||||||
{
|
{
|
||||||
PromptWindowInitData initData = (PromptWindowInitData)newData;
|
PromptWindowInitData initData = (PromptWindowInitData)newData;
|
||||||
ShowPromptWindow(initData.showMsg);
|
if (!string.IsNullOrEmpty(initData.formatKey))
|
||||||
|
{
|
||||||
|
LocalizationManager.SetFormatted(text_msg, initData.formatKey, initData.formatArgs);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowPromptWindow(initData.showMsg);
|
||||||
|
}
|
||||||
buttonSure = initData.buttonSure;//注册确定事件
|
buttonSure = initData.buttonSure;//注册确定事件
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ShowPromptWindow(string value)
|
void ShowPromptWindow(string value)
|
||||||
{
|
{
|
||||||
|
// If the value is already localized (from Format/Get), set directly.
|
||||||
|
// RefreshAll will handle re-translation if the source key is found.
|
||||||
text_msg.text = value;
|
text_msg.text = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,10 +74,19 @@ public class PromptWindowInitData
|
|||||||
{
|
{
|
||||||
public string showMsg;
|
public string showMsg;
|
||||||
public UnityAction buttonSure;//确认操作按钮
|
public UnityAction buttonSure;//确认操作按钮
|
||||||
|
public string formatKey; // localization key for SetFormatted
|
||||||
|
public object[] formatArgs; // args for SetFormatted
|
||||||
|
|
||||||
public PromptWindowInitData(string msg, UnityAction action)
|
public PromptWindowInitData(string msg, UnityAction action)
|
||||||
{
|
{
|
||||||
showMsg = msg;
|
showMsg = msg;
|
||||||
buttonSure = action;
|
buttonSure = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PromptWindowInitData(string locKey, object[] args, UnityAction action)
|
||||||
|
{
|
||||||
|
formatKey = locKey;
|
||||||
|
formatArgs = args;
|
||||||
|
buttonSure = action;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user