public ApplicationContext(string[] args) { ProgramArguments = new Arguments(); ProgramLocalization = new Localization(); LocalizationsList = new Dictionary<string, Localization>(); Parser.Default.ParseArguments(args, ProgramArguments); McDirectory = ProgramArguments.WorkingDirectory ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".minecraft\\"); McLauncher = Path.Combine(McDirectory, "freelauncher\\"); McVersions = Path.Combine(McDirectory, "versions\\"); McLibs = Path.Combine(McDirectory, "libraries\\"); _configurationFile = McLauncher + "\\configuration.json"; Configuration = GetConfiguration(); LoadLocalization(); }
public void SetLocalization(string localizationName) { ProgramLocalization = string.IsNullOrEmpty(localizationName) ? new Localization() : LocalizationsList[localizationName]; }
private void LoadLocalization() { var langsDirectory = new DirectoryInfo(Path.Combine(Application.StartupPath + "\\freelauncher-langs\\")); if (!langsDirectory.Exists) { return; } foreach (var local in langsDirectory .GetFiles() .Where(file => file.Name.Contains("lang")) .Select(file => JObject.Parse(File.ReadAllText(file.FullName))) .Select(jo => JsonConvert.DeserializeObject<Localization>(jo.ToString()))) { LocalizationsList.Add(local.LanguageTag, local); if (local.LanguageTag == Configuration.SelectedLanguage) { ProgramLocalization = local; } } }