Skip to content

Commit 0ecf1f2

Browse files
authored
Character name loc key fix (#374) #patch
* Replace spaces with underscores in character loc keys * Fix loc setting
1 parent 6ccb931 commit 0ecf1f2

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

ImperatorToCK3/CK3/Characters/Character.cs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -123,29 +123,16 @@ Date ck3BookmarkDate
123123
if (!string.IsNullOrEmpty(ImperatorCharacter.CustomName)) {
124124
var loc = ImperatorCharacter.CustomName;
125125
Name = "IMPTOCK3_CUSTOM_NAME_" + loc.Replace(' ', '_');
126-
Localizations.Add(Name, new LocBlock {
127-
english = loc,
128-
french = loc,
129-
german = loc,
130-
russian = loc,
131-
simp_chinese = loc,
132-
spanish = loc
133-
});
126+
Localizations.Add(Name, new LocBlock(loc));
134127
} else {
135-
Name = ImperatorCharacter.Name;
128+
var nameLoc = ImperatorCharacter.Name;
129+
Name = nameLoc.Replace(' ', '_');
136130
if (!string.IsNullOrEmpty(Name)) {
137-
var impNameLoc = localizationMapper.GetLocBlockForKey(Name);
138-
if (impNameLoc is not null) {
139-
Localizations.Add(Name, impNameLoc);
131+
var matchedLocBlock = localizationMapper.GetLocBlockForKey(Name);
132+
if (matchedLocBlock is not null) {
133+
Localizations.Add(Name, matchedLocBlock);
140134
} else { // fallback: use unlocalized name as displayed name
141-
Localizations.Add(Name, new LocBlock {
142-
english = Name,
143-
french = Name,
144-
german = Name,
145-
russian = Name,
146-
simp_chinese = Name,
147-
spanish = Name
148-
});
135+
Localizations.Add(Name, new LocBlock(nameLoc));
149136
}
150137
}
151138
}

ImperatorToCK3/Imperator/Characters/CharacterName.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace ImperatorToCK3.Imperator.Characters {
44
public class CharacterName : Parser {
5-
public string Name { get; private set; } = string.Empty; // key for localization
5+
public string Name { get; private set; } = string.Empty; // key for localization or literal name
66
public string? CustomName { get; private set; } // localized
77

88
public CharacterName(BufferedReader reader) {

0 commit comments

Comments
 (0)