Skip to content

Commit dbe159a

Browse files
authored
Fix replacement loc for TFE being outputted even when the mod isn't used (#2607) #patch
Converted the zz_IRToCK3_tfe_override_l_english.yml file to a Liquid template file, which is rendered empty when TFE isn't used.
1 parent 2d4de10 commit dbe159a

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
l_english:
1+
{% if tfe %}
2+
l_english:
23
# MUST READ:
34
# for every overridden loc, explain why we're overriding it!
45

@@ -72,4 +73,5 @@
7273
# Key is missing localization: TFE_gladiator_completed_log_entry_title
7374
# Key is missing localization: TFE_chariot_completed_log_entry_title
7475
TFE_gladiator_completed_log_entry_title: "$TFE_gladiator_completed_log_title$"
75-
TFE_chariot_completed_log_entry_title: "$TFE_chariot_completed_log_title$"
76+
TFE_chariot_completed_log_entry_title: "$TFE_chariot_completed_log_title$"
77+
{% endif %}

ImperatorToCK3/Outputter/WorldOutputter.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,19 @@ public static void CopyBlankModFilesToOutput(string outputPath, OrderedDictionar
105105
// Hash expects the dictionary values to be of type object, so we need to cast the bools to objects.
106106
var convertedModFlags = ck3ModFlags.ToDictionary(kv => kv.Key, kv => (object)kv.Value);
107107
var context = Hash.FromDictionary(convertedModFlags);
108-
109-
// In the output path, find .liquid files, parse them with DotLiquid and write them back as .txt files.
108+
109+
// In the output path, find .liquid files, parse them with DotLiquid and write them back without the .liquid extension.
110+
// For example, this will convert file.txt.liquid to file.txt and loc.yml.liquid to loc.yml.
110111
var liquidFiles = Directory.GetFiles(outputPath, "*.liquid", SearchOption.AllDirectories);
111112
foreach (var liquidFilePath in liquidFiles) {
112113
var liquidText = File.ReadAllText(liquidFilePath);
113114
var template = Template.Parse(liquidText);
114115
var result = template.Render(context);
115-
var txtFilePath = liquidFilePath[..^7] + ".txt";
116-
// Write the result to a .txt file and delete the .liquid file. Use UTF8-BOM encoding.
117-
File.WriteAllText(txtFilePath, result, new UTF8Encoding(encoderShouldEmitUTF8Identifier: true));
116+
var renderedFilePath = liquidFilePath[..^7];
117+
// Write the rendered file and delete the .liquid file. Use UTF8-BOM encoding.
118+
File.WriteAllText(renderedFilePath, result, new UTF8Encoding(encoderShouldEmitUTF8Identifier: true));
118119
File.Delete(liquidFilePath);
119-
Logger.Debug("Converted " + liquidFilePath + " to " + txtFilePath);
120+
Logger.Debug("Converted " + liquidFilePath + " to " + renderedFilePath);
120121
}
121122

122123
Logger.IncrementProgress();

0 commit comments

Comments
 (0)