static void ImportStringTable(MenuCommand command) { var table = command.context as StringTable; Assert.IsTrue(table != null, "Expected StringTable"); var path = EditorUtility.OpenFilePanel($"Import CSV into {table.TableData}({table.LocaleIdentifier})", PreviousDirectory, "csv"); if (string.IsNullOrEmpty(path)) { return; } EditorPrefs.SetString(kPrefFile, path); var collection = LocalizationEditorSettings.GetCollectionFromTable(table) as StringTableCollection; if (collection == null) { Debug.LogError("String Table must belong to a StringTableCollection."); return; } var cellMappings = new CsvColumns[] { new KeyIdColumns(), new LocaleColumns { LocaleIdentifier = table.LocaleIdentifier } }; using (var stream = new StreamReader(path)) { var reporter = TaskReporter.CreateDefaultReporter(); reporter.Start("Importing " + path, string.Empty); Csv.ImportInto(stream, collection, cellMappings, true, reporter); } }
static void Import(string path, StringTableCollection collection, IList <CsvColumns> columns) { using (var stream = new StreamReader(path)) { var reporter = TaskReporter.CreateDefaultReporter(); reporter.Start("Importing " + path, string.Empty); Csv.ImportInto(stream, collection, columns, true, reporter); } }
static void Export(string path, StringTableCollection collection, IList <CsvColumns> columns) { using (var stream = new StreamWriter(path, false, Encoding.UTF8)) { var reporter = TaskReporter.CreateDefaultReporter(); reporter.Start("Exporting " + path, string.Empty); Csv.Export(stream, collection, columns, reporter); } }
public static void ImportXliffFile() { var file = EditorUtility.OpenFilePanel("Import XLIFF", "", "xlf"); if (string.IsNullOrEmpty(file)) { return; } Xliff.ImportFile(file, null, TaskReporter.CreateDefaultReporter()); }
public static void ImportXliffDirectory() { var dir = EditorUtility.OpenFolderPanel("Import XLIFF from directory", EditorPrefs.GetString(kPrefXliffDirectory, ""), ""); if (string.IsNullOrEmpty(dir)) { return; } EditorPrefs.SetString(kPrefXliffDirectory, dir); Xliff.ImportDirectory(dir, null, TaskReporter.CreateDefaultReporter()); }
public static void ImportIntoCollection(MenuCommand command) { var collection = command.context as StringTableCollection; Debug.Assert(collection != null, "Expected StringTableCollection"); var file = EditorUtility.OpenFilePanel("Import XLIFF", EditorPrefs.GetString(kPrefXliffFile, ""), "xlf"); if (string.IsNullOrEmpty(file)) { return; } EditorPrefs.SetString(kPrefXliffFile, file); Xliff.ImportFileIntoCollection(collection, file, null, TaskReporter.CreateDefaultReporter()); }
static void Export(IList <CsvColumns> cellMappings, StringTableCollection collection) { var path = EditorUtility.SaveFilePanel($"Export {collection.TableCollectionName} to CSV", PreviousDirectory, collection.TableCollectionName, "csv"); if (string.IsNullOrEmpty(path)) { return; } EditorPrefs.SetString(kPrefFile, path); using (var stream = new StreamWriter(path, false, Encoding.UTF8)) { var reporter = TaskReporter.CreateDefaultReporter(); reporter.Start("Exporting " + path, string.Empty); Csv.Export(stream, collection, cellMappings, reporter); } }
public static void ImportCollection(MenuCommand command) { var collection = command.context as StringTableCollection; Assert.IsTrue(collection != null, "Expected StringTableCollection"); var path = EditorUtility.OpenFilePanel($"Import CSV into {collection.TableCollectionName}", PreviousDirectory, "csv"); if (string.IsNullOrEmpty(path)) { return; } EditorPrefs.SetString(kPrefFile, path); using (var stream = new StreamReader(path)) { var reporter = TaskReporter.CreateDefaultReporter(); reporter.Start("Importing " + path, string.Empty); Csv.ImportInto(stream, collection, true, reporter); } }
void DrawSyncControls(JsonExtensionPropertyDrawerData data, SerializedProperty property, ref Rect position) { // EditorGUI.PropertyField(position, data.m_RemoveMissingPulledKeys); // position.MoveToNextLine(); // Disable if we have no destination sheet. var splitRow = position.SplitHorizontal(); position.MoveToNextLine(); if (data.PushTask != null && data.PushTask.IsCompleted) { // var target = property.GetActualObjectForSerializedProperty<GoogleSheetsExtension>(fieldInfo); // var collection = target.TargetCollection as StringTableCollection; // var currentPushRequest = s_PushRequests.FirstOrDefault(tc => ReferenceEquals(tc.collection, collection)); // s_PushRequests.Remove(currentPushRequest); data.PushTask = null; } using (new EditorGUI.DisabledGroupScope(data.PushTask != null || string.IsNullOrEmpty(data.m_TableId.stringValue) || data.FieldsList.count == 0)) { using (new EditorGUI.DisabledGroupScope(data.FieldsList.index < 0)) { if (GUI.Button(splitRow.left, Styles.pushSelected)) { // var google = GetGoogleSheets(data); // var target = property.GetActualObjectForSerializedProperty<GoogleSheetsExtension>(fieldInfo); // var selectedCollection = GetSelectedColumns(data.columnsList.index, property); // var collection = target.TargetCollection as StringTableCollection; // data.pushTask = google.PushStringTableCollectionAsync(data.m_SheetId.intValue, collection, selectedCollection, TaskReporter.CreateDefaultReporter()); // s_PushRequests.Add((collection, data.pushTask)); } if (GUI.Button(splitRow.right, Styles.pullSelected)) { // var google = GetGoogleSheets(data); // var target = property.GetActualObjectForSerializedProperty<GoogleSheetsExtension>(fieldInfo); // var selectedCollection = GetSelectedColumns(data.columnsList.index, property); // google.PullIntoStringTableCollection(data.m_SheetId.intValue, target.TargetCollection as StringTableCollection, selectedCollection, data.m_RemoveMissingPulledKeys.boolValue, TaskReporter.CreateDefaultReporter(), true); } } splitRow = position.SplitHorizontal(); position.MoveToNextLine(); if (GUI.Button(splitRow.left, Styles.push)) { // var google = GetGoogleSheets(data); // var target = property.GetActualObjectForSerializedProperty<GoogleSheetsExtension>(fieldInfo); // var collection = target.TargetCollection as StringTableCollection; // data.pushTask = google.PushStringTableCollectionAsync(data.m_SheetId.intValue, collection, target.Columns, TaskReporter.CreateDefaultReporter()); // s_PushRequests.Add((collection, data.pushTask)); } if (GUI.Button(splitRow.right, Styles.pull)) { var google = GetTableContent(data); var target = property.GetActualObjectForSerializedProperty <JsonExtension>(fieldInfo); google.PullIntoStringTableCollection(target.TargetCollection as StringTableCollection, target.Fields, data.m_RemoveMissingPulledKeys.boolValue, TaskReporter.CreateDefaultReporter(), true); } } }
static void ImportIntoTable(MenuCommand command) { var table = command.context as StringTable; Debug.Assert(table != null, "Expected StringTable"); var file = EditorUtility.OpenFilePanel("Import XLIFF", EditorPrefs.GetString(kPrefXliffFile, ""), "xlf"); if (string.IsNullOrEmpty(file)) { return; } EditorPrefs.SetString(kPrefXliffFile, file); Xliff.ImportFileIntoTable(file, table, Xliff.ImportNotesBehavior.Replace, TaskReporter.CreateDefaultReporter()); }