public bool TryTranslateFullName(CharacterSex sex, string origName, out string result) { if (_hasEntries && _fullNameCache[sex].TryGetValue(origName, out result)) { if (!TranslationHelper.NameStringComparer.Equals(origName, result) && !StringUtils.ContainsJapaneseChar(result)) { CardNameTranslationManager.CacheRecentTranslation(new NameScope(sex), origName, result); } return(true); } result = null; return(false); }
// ReSharper disable Unity.PerformanceAnalysis public bool TryTranslateCardNames(ChaFile chaFile, out Dictionary <string, string> result) { var origName = chaFile.GetFullName(); if (!_hasEntries) { result = null; return(false); } void PopulateResult(IDictionary <string, string> output, string nameType, string nameValue) { if (nameValue != null) { output[nameType] = nameValue; } } result = null; var key = new CardNameCacheKey(chaFile); var sex = chaFile.GetSex(); if (!_cardCache[sex].TryGetValue(key, out var match)) { return(false); } result = new Dictionary <string, string>(GeBoAPI.Instance.ChaFileNameCount); PopulateResult(result, "fullname", match.FullName); PopulateResult(result, "firstname", match.GivenName); PopulateResult(result, "lastname", match.FamilyName); var fullName = BuildFullName(match); if (!StringUtils.ContainsJapaneseChar(fullName)) { CardNameTranslationManager.CacheRecentTranslation(new NameScope(sex), origName, fullName); var fullPath = chaFile.GetFullPath(); if (!string.IsNullOrEmpty(fullPath)) { CharaFileInfoTranslationManager.CacheRecentTranslation( new NameScope(chaFile.GetSex()), fullPath, fullName); } } var origNick = chaFile.GetName("nickname"); if (string.IsNullOrEmpty(origNick)) { return(true); } if (_nickNameCache[sex].TryGetValue(key, out var nickLookup) && nickLookup.TryGetValue(origNick, out var translatedNick)) { PopulateResult(result, "nickname", translatedNick); } else if (key.GivenName == origNick) { PopulateResult(result, "nickname", match.GivenName); } return(true); }