예제 #1
0
        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);
            }
        }
예제 #2
0
 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);
     }
 }
예제 #3
0
 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);
     }
 }
예제 #4
0
파일: MenuItems.cs 프로젝트: Habi-Thapa/csv
        public static void ImportXliffFile()
        {
            var file = EditorUtility.OpenFilePanel("Import XLIFF", "", "xlf");

            if (string.IsNullOrEmpty(file))
            {
                return;
            }

            Xliff.ImportFile(file, null, TaskReporter.CreateDefaultReporter());
        }
예제 #5
0
파일: MenuItems.cs 프로젝트: Habi-Thapa/csv
        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());
        }
예제 #6
0
파일: MenuItems.cs 프로젝트: Habi-Thapa/csv
        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());
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
        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);
                }
            }
        }
예제 #10
0
파일: MenuItems.cs 프로젝트: Habi-Thapa/csv
        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());
        }