2[
WorkbenchPluginAttribute(name:
"Modified Localisation Plugin", wbModules: {
"LocalizationEditor" }, awesomeFontCode: 0xF246)]
3class SCR_LocModifiedPlugin : LocalizationEditorPlugin
6 protected string UserName;
9 protected string GetUserName()
11 if (UserName.IsEmpty())
12 Workbench.GetUserName(UserName);
20 Workbench.ScriptDialog(
"Configure Modified Localisation Plugin",
"",
this);
30 override void OnChange(
BaseContainer stringTableItem,
string propName,
string propValue)
32 LocalizationEditor editor = Workbench.GetModule(LocalizationEditor);
33 editor.ModifyProperty(stringTableItem, stringTableItem.GetVarIndex(
"Modified"), Workbench.GetPackedUtcTime().ToString());
35 string userName = GetUserName();
38 editor.ModifyProperty(stringTableItem, stringTableItem.GetVarIndex(
"Author"), userName);
40 editor.ModifyProperty(stringTableItem, stringTableItem.GetVarIndex(
"LastChanged"), userName);
46 newItem.Set(
"Modified", Workbench.GetPackedUtcTime());
48 string userName = GetUserName();
51 newItem.Set(
"LastChanged", userName);
53 newItem.Set(
"Author", userName);
58class SCR_LocExportPlugin : LocalizationEditorPlugin
61 override string GetExportColumn(
BaseContainer item,
string languageCode)
63#ifndef LOCALIZATION_BUILD_HIDDEN
65 item.Get(
"Hidden", hidden);
70 if (languageCode ==
"en_us")
73 item.Get(
"Target_en_us_edited", edited);
75 if (!edited.IsEmpty())
76 return "Target_en_us_edited";
81 item.Get(
"Target_"+languageCode, translation);
82 if (translation.IsEmpty())
83 return "Target_en_us";
86 return "Target_" + languageCode;
104class SCR_LocLengthPlugin : LocalizationEditorPlugin
109 LocalizationEditor editor = Workbench.GetModule(LocalizationEditor);
114 array<int> indices = {};
115 array<string> targets;
120 for (
int iRow, count = rows.Count(); iRow < count; iRow++)
126 targets =
new array<string>;
127 for (
int iCol; iCol < row.GetNumVars(); iCol++)
129 string colName = row.GetVarName(iCol);
130 if (colName.Contains(
"Target_"))
131 targets.Insert(colName);
138 foreach (
string targetCol : targets)
141 row.Get(
"MaxLength", maxLength);
146 row.Get(targetCol, targetText);
148 if (targetText.Length() > maxLength)
150 indices.Insert(iRow);
151 Print(
string.Format(
"LocLengthPlugin: ID: '%1', %2: '%3' is too long (%4/%5)",
ID, targetCol, targetText, targetText.Length(), maxLength),
LogLevel.NORMAL);
157 if (!indices.IsEmpty())
158 editor.AddUserFilter(indices,
"Long texts");
class WorkbenchDialog_AbortRetryIgnore ButtonAttribute("OK", true)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
SCR_FieldOfViewSettings Attribute
@ ID
Ordered by Group application ID.