@@ -137,6 +137,17 @@ internal string GetString(string Key, bool tag = true)
137
137
Info ( $ "获取失败 Key{ Key } Language{ CurrentLang } ") ;
138
138
return tag ? $ "'{ Key } '" : Key ;
139
139
}
140
+
141
+ internal readonly List < TranslateNode > _translateNodes = [ ] ;
142
+ }
143
+
144
+ public class TranslateNode ( string id , string [ ] ? values = null , TranslateNode [ ] ? nodes = null )
145
+ {
146
+ public string Id { get ; set ; } = id ;
147
+ public string [ ] ? Values { get ; set ; } = values ;
148
+ public TranslateNode [ ] ? _nodes { get ; set ; } = nodes ;
149
+
150
+ public string Def => Values ? [ 0 ] ?? string . Empty ;
140
151
}
141
152
142
153
[ Harmony ]
@@ -147,7 +158,7 @@ internal static class LanguageExtension
147
158
private static void OnTranslationController_Initialized_Load ( TranslationController __instance )
148
159
{
149
160
LanguageManager . Instance . CurrentLang = __instance . currentLanguage . languageID ;
150
- TheOtherRolesPlugin . OnTranslationController_Initialized_Load ( ) ;
161
+ Main . OnTranslationController_Initialized_Load ( ) ;
151
162
}
152
163
153
164
[ HarmonyPatch ( typeof ( TranslationController ) , nameof ( TranslationController . SetLanguage ) ) ]
@@ -161,4 +172,20 @@ internal static string Translate(this string key)
161
172
{
162
173
return LanguageManager . Instance . GetString ( key ) ;
163
174
}
175
+ internal static string Get ( params string [ ] strings )
176
+ {
177
+ TranslateNode ? node = null ;
178
+ var count = 1 ;
179
+ foreach ( var str in strings )
180
+ {
181
+ node = count == 1 ? LanguageManager . Instance . _translateNodes . FirstOrDefault ( n => n . Id == str ) : node ? . _nodes . FirstOrDefault ( n => n . Id == str ) ;
182
+
183
+ if ( node == null )
184
+ return string . Empty ;
185
+
186
+ count ++ ;
187
+ }
188
+
189
+ return node ? . Def ?? string . Empty ;
190
+ }
164
191
}
0 commit comments