Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ LoadLanguageFromFileTextCsv()

void Terraria.Localization.LanguageManager.LoadLanguageFromFileTextCsv ( string fileText)
inline

Definition at line 211 of file LanguageManager.cs.

212 {
213 //IL_0008: Unknown result type (might be due to invalid IL or missing references)
214 //IL_000e: Expected O, but got Unknown
215 using TextReader textReader = new StringReader(fileText);
216 CsvReader val = new CsvReader(textReader);
217 try
218 {
219 val.Configuration.HasHeaderRecord = true;
220 if (!val.ReadHeader())
221 {
222 return;
223 }
224 string[] fieldHeaders = val.FieldHeaders;
225 int num = -1;
226 int num2 = -1;
227 for (int i = 0; i < fieldHeaders.Length; i++)
228 {
229 string text = fieldHeaders[i].ToLower();
230 if (text == "translation")
231 {
232 num2 = i;
233 }
234 if (text == "key")
235 {
236 num = i;
237 }
238 }
239 if (num == -1 || num2 == -1)
240 {
241 return;
242 }
243 int num3 = Math.Max(num, num2) + 1;
244 while (val.Read())
245 {
246 string[] currentRecord = val.CurrentRecord;
247 if (currentRecord.Length >= num3)
248 {
249 string text2 = currentRecord[num];
250 string value = currentRecord[num2];
251 if (!string.IsNullOrWhiteSpace(text2) && !string.IsNullOrWhiteSpace(value) && _localizedTexts.ContainsKey(text2))
252 {
253 _localizedTexts[text2].SetValue(value);
254 }
255 }
256 }
257 }
258 finally
259 {
260 ((IDisposable)val)?.Dispose();
261 }
262 }
static byte Max(byte val1, byte val2)
Definition Math.cs:738
readonly Dictionary< string, LocalizedText > _localizedTexts

References Terraria.Localization.LanguageManager._localizedTexts, System.Collections.Generic.Dictionary< TKey, TValue >.ContainsKey(), System.Text.RegularExpressions.i, System.Math.Max(), System.text, and System.value.

Referenced by Terraria.Localization.LanguageManager.UseSources().