File tree Expand file tree Collapse file tree 5 files changed +1788
-0
lines changed Expand file tree Collapse file tree 5 files changed +1788
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,8 @@ public static void Postfix()
9191 Vocabulary . keyWords = ApplyLocalization ( Vocabulary . keyWords ) ;
9292 Vocabulary . keyWordsExp = ApplyLocalization ( Vocabulary . keyWordsExp ) ;
9393 Vocabulary . categoryToStr = ApplyLocalization ( Vocabulary . categoryToStr ) ;
94+ Vocabulary . VrbToStr = ApplyLocalization ( Vocabulary . VrbToStr ) ;
95+ Vocabulary . AuxToStr = ApplyLocalization ( Vocabulary . AuxToStr ) ;
9496 }
9597
9698 var fi = AccessTools . Field ( typeof ( GameProgress ) , "values" ) ;
@@ -128,6 +130,24 @@ public static void Postfix(ref string __result)
128130 }
129131 }
130132 }
133+
134+ [ HarmonyPatch ( typeof ( Lang ) , nameof ( Lang . LoadResource ) ) ]
135+ public static class LangFix2
136+ {
137+ public static void Postfix ( )
138+ {
139+ var fi = AccessTools . Field ( typeof ( Lang ) , "dictionary" ) ;
140+ var val = fi . GetValue ( null ) as Dictionary < string , string > ;
141+ if ( val == null )
142+ {
143+ Logger . Error ( $ "Failed to Get Field dictionary") ;
144+ }
145+ foreach ( var ele in TranslationDB . VocabularyInfo2 )
146+ {
147+ val [ ele . Key ] = ele . Value ;
148+ }
149+ }
150+ }
131151
132152 [ HarmonyPatch ( typeof ( PlayableCharacter ) , nameof ( PlayableCharacter . LoadResource ) ) ]
133153 public static class CharacterFix
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ public static class TranslationDB
1212 public static Dictionary < string , TranslationItem > CardInfo = null ;
1313 public static Dictionary < string , TranslationItem > EnchantInfo = null ;
1414 public static Dictionary < string , string > VocabularyInfo = null ;
15+ public static Dictionary < string , string > VocabularyInfo2 = null ;
1516 public static Dictionary < string , string > ScenarioInfo = null ;
1617 public static Dictionary < string , TranslationItem > LangDescription = null ;
1718 public static Dictionary < string , string > EntityInfo = null ;
@@ -139,6 +140,26 @@ public static void Init()
139140
140141 EntityInfo = dst ;
141142 }
143+
144+ {
145+ // 读取 JSON 文件内容
146+ string jsonContent = File . ReadAllText (
147+ Path . Join ( modPath , "vocabulary2_translated.json" ) ) ;
148+
149+ // 反序列化 JSON 字符串为 TranslationItem 结构体的列表
150+ var items = JsonConvert . DeserializeObject < List < TranslationItem > > ( jsonContent ) ;
151+ var dst = new Dictionary < string , string > ( ) ;
152+ foreach ( var item in items )
153+ {
154+ if ( ! dst . TryAdd ( item . Key , item . Translation ) )
155+ {
156+ Logger . Log ( $ "Find Duplicated Item { item . Key } { item . Original } , content { item . Translation } ") ;
157+ continue ;
158+ }
159+ }
160+
161+ VocabularyInfo2 = dst ;
162+ }
142163 }
143164
144165
You can’t perform that action at this time.
0 commit comments