2018-04-22 15:04:18 -05:00
|
|
|
|
using SharedLibraryCore;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin.Application.Localization
|
|
|
|
|
{
|
|
|
|
|
public class Configure
|
|
|
|
|
{
|
|
|
|
|
public static void Initialize()
|
|
|
|
|
{
|
2018-04-24 17:01:27 -05:00
|
|
|
|
string currentLocale = Program.ServerManager.GetApplicationSettings().Configuration().CustomLocale ??
|
|
|
|
|
CultureInfo.CurrentCulture.Name.Substring(0, 2);
|
2018-04-23 00:43:48 -05:00
|
|
|
|
#if DEBUG
|
2018-04-23 16:03:50 -05:00
|
|
|
|
// currentLocal = "ru-RU";
|
2018-04-23 00:43:48 -05:00
|
|
|
|
#endif
|
2018-04-24 17:01:27 -05:00
|
|
|
|
string localizationFile = $"Localization{Path.DirectorySeparatorChar}IW4MAdmin.{currentLocale}-{currentLocale.ToUpper()}.json";
|
2018-04-22 15:04:18 -05:00
|
|
|
|
string localizationContents;
|
|
|
|
|
|
|
|
|
|
if (File.Exists(localizationFile))
|
|
|
|
|
{
|
2018-04-24 17:01:27 -05:00
|
|
|
|
localizationContents = File.ReadAllText(localizationFile, Encoding.UTF8);
|
2018-04-22 15:04:18 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
localizationFile = $"Localization{Path.DirectorySeparatorChar}IW4MAdmin.en-US.json";
|
2018-04-23 00:43:48 -05:00
|
|
|
|
localizationContents = File.ReadAllText(localizationFile, Encoding.UTF8);
|
2018-04-22 15:04:18 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utilities.CurrentLocalization = Newtonsoft.Json.JsonConvert.DeserializeObject<SharedLibraryCore.Localization.Layout>(localizationContents);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|