public LocalizationGroup(LocalizationPack pack, string packPath, string name, bool allowCreateDirectoryIfNeeded = false) { Pack = pack; PackPath = packPath; Name = name; if (!Directory.Exists(GroupPath)) { if (allowCreateDirectoryIfNeeded) { try { Directory.CreateDirectory(GroupPath); } catch (IOException e) { Debug.LogError("ORLL: LocalizationGroup: Failed to create the directory of the group."); throw; } } else { Debug.LogError($"ORLL: LocalizationGroup: Directory of the group \"{name}\" ({GroupPath}) was not found. You can create a directory automatically by specifying allowCreateDirectoryIfNeeded option."); throw new ArgumentException("Group was not found."); } } UnitNames = GetUnitNames(); }
internal void SwitchPack(LocalizationPack newPack) { foreach (var group in Groups) { group.OnCurrentPackChanged(newPack); } }
public LocalizationPack CreatePack(string folderName, string name) { var pack = new LocalizationPack(Guid.NewGuid().ToString(), name, name, "", "", ""); var folderPath = Path.GetDirectoryName(RootPath.TrimEnd('/', '\\') + Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar + folderName + pack.Guid; var packPath = folderPath.TrimEnd('\\', '/') + Path.DirectorySeparatorChar + folderName + ".lcpack"; Directory.CreateDirectory(folderPath); pack.Initialize(packPath, true); packs.Add(pack); return(pack); }
public void RemovePack(LocalizationPack pack) { if (!packs.Contains(pack)) { return; } string packPath = pack.PackPath; Debug.Log(Path.GetDirectoryName(packPath)); Directory.Delete(Path.GetDirectoryName(pack.PackPath), true); packs.Remove(pack); }
public void OnCurrentPackChanged(LocalizationPack newPack) { var newGroup = newPack.Groups.FirstOrDefault(p => p.Name == this.Name); if (newGroup != null) { foreach (var reference in References) { reference.Migrate(newGroup); } } }
public void SwitchPack(LocalizationPack newPack) { if (!Packs.Contains(newPack)) { Debug.LogError($"ORLL: Localizer: Specified pack \"{newPack.Name}\" is not loaded on current localizer instance."); return; } var old = CurrentPack; if (old == newPack) { return; } CurrentPack = newPack; old.SwitchPack(newPack); Debug.Log($"ORLL: Localizer: \"{newPack.Name}\" was set as default pack."); }