//--------------------// #region Handlers /// <inheritdoc/> protected override void OnInitialize() { #region File handling if (Path.IsPathRooted(FilePath)) { _fullPath = FilePath; if (!_overwrite && File.Exists(_fullPath)) { // Load existing file Log.Info("Load file: " + _fullPath); locale = LocaleFile.Load(_fullPath); } else { // Create new file Log.Info("Create file: " + _fullPath); locale = new XmlDictionary { { "Test", "A" } }; LocaleFile.Save(_fullPath, locale); } } else { // File name only? Might not save to same dir loaded from! Log.Info("Load file: " + FilePath); locale = LocaleFile.FromContent(FilePath); _fullPath = ContentManager.CreateFilePath("GUI/Language", FilePath); } #endregion base.OnInitialize(); }
/// <inheritdoc/> protected override void OnSaveFile() { // Sort alphabetically before saving locale.Sort(); // OnUpdate() will automatically be called Log.Info("Save file: " + _fullPath); string directory = Path.GetDirectoryName(_fullPath); if (!string.IsNullOrEmpty(directory)) { Directory.CreateDirectory(directory); } LocaleFile.Save(_fullPath, locale); base.OnSaveFile(); }