Skip to content

Commit 8e14b39

Browse files
committed
Add all missing EditorMessageBox translation keys to Translation_en.ini, adjust some translation keys, update documentation
1 parent a3856f3 commit 8e14b39

File tree

14 files changed

+226
-47
lines changed

14 files changed

+226
-47
lines changed
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
1+
; C&C World-Altering Editor
2+
; Translation language list file
3+
; https://github.com/CnCNet/WorldAlteringEditor
4+
5+
6+
; Defines all languages available in the editor.
7+
; The editor expects this file to contain a separate section for all languages defined in this file.
18
[Translations]
29
0=English
310

11+
12+
; Individual language control sections.
13+
; Available keys:
14+
; UIName=Name of the language as shown in the user-interface.
15+
;
16+
; Directory=<string>, specifies the sub-directory inside the Translations folder that the translation's files exist in.
17+
; Also used as the suffix in translation file names (for example, if Directory=en, the editor reads
18+
; ObjectNames_en.ini and Translation_en.ini). Should always be just a short, internationally understood
19+
; language identifier.
20+
;
21+
; IniFileEncoding=<int> can define an encoding codepage for the INI parser to use when reading the languages's INI files.
22+
; If unspecified, the editor defaults to UTF-8 (which should be generally sufficient).
23+
;
24+
; IsReference=<bool>, if set to yes/true, then the translation is treated as a "reference language" and its translation file
25+
; is not actually used, but default strings are returned instead. Should not be used for anything else than English.
26+
427
[English]
528
UIName=English
629
Directory=en
7-
30+
IsReference=yes

src/TSMapEditor/Config/Translations/en/Translation_en.ini

Lines changed: 145 additions & 2 deletions
Large diffs are not rendered by default.

src/TSMapEditor/Misc/Translator.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class Translation
1515

1616
private static Dictionary<string, string> ObjectNames = new Dictionary<string, string>();
1717

18-
public Translation(string internalName, string directoryName, string uiName, int index)
18+
public Translation(string internalName, string directoryName, string uiName, int index, bool isReference)
1919
{
2020
if (string.IsNullOrWhiteSpace(internalName))
2121
throw new ArgumentException("Translation internal name cannot be empty.");
@@ -27,6 +27,7 @@ public Translation(string internalName, string directoryName, string uiName, int
2727
DirectoryName = directoryName;
2828
UIName = uiName;
2929
Index = index;
30+
IsReference = isReference;
3031
}
3132

3233
public Translation(IniSection definitionSection, int index)
@@ -40,10 +41,12 @@ public Translation(IniSection definitionSection, int index)
4041
if (string.IsNullOrWhiteSpace(DirectoryName))
4142
throw new InvalidOperationException("DirectoryName cannot be empty for a translation. Translation section: " + definitionSection.SectionName);
4243

43-
UIName = definitionSection.GetStringValue("UIName", null);
44+
UIName = definitionSection.GetStringValue(nameof(UIName), null);
4445
if (string.IsNullOrWhiteSpace(UIName))
4546
throw new InvalidOperationException("UIName cannot be empty for a translation. Translation section: " + definitionSection.SectionName);
4647

48+
IsReference = definitionSection.GetBooleanValue(nameof(IsReference), false);
49+
4750
if (definitionSection.KeyExists(nameof(IniFileEncoding)))
4851
{
4952
IniFileEncoding = Encoding.GetEncoding(definitionSection.GetIntValue(nameof(IniFileEncoding), 0));
@@ -62,6 +65,8 @@ public Translation(IniSection definitionSection, int index)
6265

6366
public int Index { get; }
6467

68+
public bool IsReference { get; }
69+
6570
private string ProcessEscapes(string str)
6671
{
6772
return str.Replace("\\s", " ").Replace("@", Environment.NewLine);
@@ -117,6 +122,15 @@ public void Load()
117122

118123
public string Translate(string identifier, string defaultString)
119124
{
125+
// Reference translations always return the supplied default string, but still log missing values.
126+
if (IsReference)
127+
{
128+
if (defaultString != null && !MissingValues.ContainsKey(identifier))
129+
MissingValues[identifier] = defaultString;
130+
131+
return defaultString;
132+
}
133+
120134
if (UIStringTable.TryGetValue(identifier, out var result))
121135
return result;
122136

@@ -235,7 +249,7 @@ public static void LoadTranslations()
235249
}
236250
else
237251
{
238-
var englishTranslation = new Translation("English", "en", "English", Translations.Count);
252+
var englishTranslation = new Translation("English", "en", "English", Translations.Count, true);
239253
AddTranslation(englishTranslation);
240254
}
241255
}

src/TSMapEditor/UI/TopBar/TopBarMenu.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ private void TrySaveMap()
299299
{
300300
Logger.Log("Failed to save the map file. Returned error message: " + ex.Message);
301301

302-
EditorMessageBox.Show(WindowManager, Translate(this, "MapSaveFailedTitle", "Failed to save map"),
303-
string.Format(Translate(this, "MapSaveFailedDescription",
302+
EditorMessageBox.Show(WindowManager, Translate(this, "MapSaveFailed.Title", "Failed to save map"),
303+
string.Format(Translate(this, "MapSaveFailed.Description",
304304
"Failed to write the map file. Please make sure that WAE has write access to the path." + Environment.NewLine + Environment.NewLine +
305305
"A common source of this error is trying to save the map to Program Files or another" + Environment.NewLine +
306306
"write-protected directory without running WAE with administrative rights." + Environment.NewLine + Environment.NewLine +
@@ -316,8 +316,8 @@ private void TrySaveMap()
316316

317317
private void WriteMapPreviewConfirmation()
318318
{
319-
var messageBox = EditorMessageBox.Show(WindowManager, Translate(this, "GenerateMapPreviewConfirmationTitle", "Confirmation"),
320-
Translate(this, "GenerateMapPreviewConfirmationDescription", "This will write the current minimap as the map preview to the map file." + Environment.NewLine + Environment.NewLine +
319+
var messageBox = EditorMessageBox.Show(WindowManager, Translate(this, "GenerateMapPreviewConfirmation.Title", "Confirmation"),
320+
Translate(this, "GenerateMapPreviewConfirmation.Description", "This will write the current minimap as the map preview to the map file." + Environment.NewLine + Environment.NewLine +
321321
"This provides the map with a preview if it is used as a custom map" + Environment.NewLine +
322322
"in the CnCNet Client or in-game, but is not necessary if the map will" + Environment.NewLine +
323323
"have an external preview. It will also significantly increase the size" + Environment.NewLine +

src/TSMapEditor/UI/UIManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,10 @@ private void CheckForIssuesAfterManualSave(object sender, EventArgs e)
408408

409409
EditorMessageBox.Show(WindowManager,
410410
Translate(this, "IssuesFound.Title", "Issues Found"),
411-
Translate(this, "IssuesFound.Description",
411+
string.Format(Translate(this, "IssuesFound.Description",
412412
"The map has been saved, but one or more issues have been found in the map. Please consider resolving them." +
413413
newline + newline +
414-
issuesString),
414+
"{0}"), issuesString),
415415
MessageBoxButtons.OK);
416416
}
417417
}

src/TSMapEditor/UI/Windows/AITriggersWindow.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ private void CloneForEasierDifficulties()
111111
"setting for each AI trigger to Medium and Easy, respectively." + Environment.NewLine +
112112
"This will set the current AI trigger's difficulty to Hard only." + Environment.NewLine + Environment.NewLine +
113113
"In case the AI trigger references a Primary or Secondary TeamTypes," + Environment.NewLine +
114-
"those TeamTypes and their TaskForoces would be duplicated for easier difficulties." + Environment.NewLine +
115-
"If those duplicates already exist, this action will set the AI triggers to use those " + Environment.NewLine +
116-
"TeamTypes instead." + Environment.NewLine + Environment.NewLine +
114+
"those TeamTypes and their TaskForces will be duplicated for easier" + Environment.NewLine +
115+
"difficulties. If those duplicates already exist, this action will set" + Environment.NewLine +
116+
"the AI triggers to use those TeamTypes instead." + Environment.NewLine + Environment.NewLine +
117117
"The script assumes that this AI Trigger has the words 'H' or 'Hard'" + Environment.NewLine +
118118
"in their name and in their respective TeamTypes and TaskForces." + Environment.NewLine + Environment.NewLine +
119119
"No un-do is available. Do you want to continue?"),

src/TSMapEditor/UI/Windows/ApplyINICodeWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private void BtnApplyFile_LeftClick(object sender, EventArgs e)
5555
{
5656
confirmation = Renderer.FixText(confirmation, Constants.UIDefaultFont, Width).Text;
5757

58-
var messageBox = EditorMessageBox.Show(WindowManager, Translate(this, "Confirm", "Are you sure?"),
58+
var messageBox = EditorMessageBox.Show(WindowManager, Translate(this, "ConfirmationTitle", "Are you sure?"),
5959
confirmation, MessageBoxButtons.YesNo);
6060
messageBox.YesClickedAction = (_) => ApplyCode();
6161
}

src/TSMapEditor/UI/Windows/CreateRandomTriggerSetWindow.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private bool Validate()
113113
{
114114
EditorMessageBox.Show(WindowManager,
115115
Translate(this, "ValidateMissingTriggerName.Title", "Missing Trigger Name"),
116-
Translate(this, "ValidateMissingTriggerName.Description", "Please enter a name for the triggers"),
116+
Translate(this, "ValidateMissingTriggerName.Description", "Please enter a name for the triggers."),
117117
MessageBoxButtons.OK);
118118
return false;
119119
}
@@ -122,7 +122,7 @@ private bool Validate()
122122
{
123123
EditorMessageBox.Show(WindowManager,
124124
Translate(this, "InvalidTriggersNumber.Title", "Invalid Number of Triggers"),
125-
Translate(this, "InvalidTriggersNumber.Description", "Please enter a value of 2 or more"),
125+
Translate(this, "InvalidTriggersNumber.Description", "Please enter a value of 2 or more."),
126126
MessageBoxButtons.OK);
127127
return false;
128128
}
@@ -131,7 +131,7 @@ private bool Validate()
131131
{
132132
EditorMessageBox.Show(WindowManager,
133133
Translate(this, "InvalidElapsedTime.Title", "Invalid Elapsed Time"),
134-
Translate(this, "InvalidElapsedTime.Description", "Please enter a value of 0 or more"),
134+
Translate(this, "InvalidElapsedTime.Description", "Please enter a value of 0 or more."),
135135
MessageBoxButtons.OK);
136136
return false;
137137
}
@@ -140,7 +140,7 @@ private bool Validate()
140140
{
141141
EditorMessageBox.Show(WindowManager,
142142
Translate(this, "InvalidRandomDelay.Title", "Invalid Random Delay"),
143-
Translate(this, "InvalidRandomDelay.Description", "Please enter a value of 10 or more"),
143+
Translate(this, "InvalidRandomDelay.Description", "Please enter a value of 10 or more."),
144144
MessageBoxButtons.OK);
145145
return false;
146146
}

src/TSMapEditor/UI/Windows/ExpandMapWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private void BtnApply_LeftClick(object sender, EventArgs e)
4646
EditorMessageBox.Show(WindowManager,
4747
Translate(this, "InvalidWidth.Title", "Invalid width"),
4848
string.Format(Translate(this, "InvalidWidth.Description",
49-
"The given values would make the map's width {0}.\r\nIt should be between 1 and {1}."),
49+
"The given values would make the map's width {0}." + Environment.NewLine + "It should be between 1 and {1}."),
5050
newWidth, Constants.MaxMapWidth),
5151
MessageBoxButtons.OK);
5252

@@ -59,7 +59,7 @@ private void BtnApply_LeftClick(object sender, EventArgs e)
5959
EditorMessageBox.Show(WindowManager,
6060
Translate(this, "InvalidHeight.Title", "Invalid height"),
6161
string.Format(Translate(this, "InvalidHeight.Description",
62-
"The given values would make the map's height {0}.\r\nIt should be between 0 and {1}."),
62+
"The given values would make the map's height {0}." + Environment.NewLine + "It should be between 0 and {1}."),
6363
newHeight, Constants.MaxMapHeight),
6464
MessageBoxButtons.OK);
6565

src/TSMapEditor/UI/Windows/LocalVariablesWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,14 @@ private void BtnViewVariableUsages_LeftClick(object sender, EventArgs e)
157157
{
158158
EditorMessageBox.Show(WindowManager,
159159
Translate(this, "NoUsagesFound.Title", "No usages found"),
160-
string.Format(Translate(this, "NoUsagesMessage.Description", "No triggers or scripts make use of the selected local variable '{0}'"), editedLocalVariable.Name),
160+
string.Format(Translate(this, "NoUsagesFound.Description", "No triggers or scripts make use of the selected local variable '{0}'"), editedLocalVariable.Name),
161161
MessageBoxButtons.OK);
162162
}
163163
else
164164
{
165165
EditorMessageBox.Show(WindowManager,
166166
Translate(this, "LocalVariableUsages.Title", "Local Variable Usages"),
167-
string.Format(Translate(this, "LocalVariablesUsages.Description", "The following usages were found for the selected local variable '{0}':"), editedLocalVariable.Name) + Environment.NewLine + Environment.NewLine +
167+
string.Format(Translate(this, "LocalVariableUsages.Description", "The following usages were found for the selected local variable '{0}':"), editedLocalVariable.Name) + Environment.NewLine + Environment.NewLine +
168168
string.Join(Environment.NewLine, list.Select(e => "- " + e)),
169169
MessageBoxButtons.OK);
170170
}

0 commit comments

Comments
 (0)