Skip to content

Commit

Permalink
Character name loc key fix (#374) #patch
Browse files Browse the repository at this point in the history
* Replace spaces with underscores in character loc keys

* Fix loc setting
  • Loading branch information
IhateTrains authored Nov 7, 2021
1 parent 6ccb931 commit 0ecf1f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
27 changes: 7 additions & 20 deletions ImperatorToCK3/CK3/Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,29 +123,16 @@ Date ck3BookmarkDate
if (!string.IsNullOrEmpty(ImperatorCharacter.CustomName)) {
var loc = ImperatorCharacter.CustomName;
Name = "IMPTOCK3_CUSTOM_NAME_" + loc.Replace(' ', '_');
Localizations.Add(Name, new LocBlock {
english = loc,
french = loc,
german = loc,
russian = loc,
simp_chinese = loc,
spanish = loc
});
Localizations.Add(Name, new LocBlock(loc));
} else {
Name = ImperatorCharacter.Name;
var nameLoc = ImperatorCharacter.Name;
Name = nameLoc.Replace(' ', '_');
if (!string.IsNullOrEmpty(Name)) {
var impNameLoc = localizationMapper.GetLocBlockForKey(Name);
if (impNameLoc is not null) {
Localizations.Add(Name, impNameLoc);
var matchedLocBlock = localizationMapper.GetLocBlockForKey(Name);
if (matchedLocBlock is not null) {
Localizations.Add(Name, matchedLocBlock);
} else { // fallback: use unlocalized name as displayed name
Localizations.Add(Name, new LocBlock {
english = Name,
french = Name,
german = Name,
russian = Name,
simp_chinese = Name,
spanish = Name
});
Localizations.Add(Name, new LocBlock(nameLoc));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/Imperator/Characters/CharacterName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

public CharacterName(BufferedReader reader) {
Expand Down

0 comments on commit 0ecf1f2

Please sign in to comment.