void ShowExportGUI()
        {
            if (GUILayout.Button("Export"))
            {
                string folderPath = EditorUtility.OpenFolderPanel("Select folder to save to.", "", "");
                if (availableFileFormats[chosenFileFormat] == csvFileEnding)
                {
                    string fullPath = folderPath + "/" + exportFileName + csvFileEnding;
                    CSVParser.Write(fullPath, CSVParser.GetDelimiter(delimiter),
                                    new List <string>(LanguageHandlerEditor.LoadLanguageFile(null, true).Keys), LanguageHandlerEditor.LoadAllLanguageFiles());

                    Debug.Log("Exported CSV file to " + fullPath);
                    this.Close();
                }
                else if (availableFileFormats[chosenFileFormat] == xlsFileEnding)
                {
                    string fullPath = folderPath + "/" + exportFileName + xlsFileEnding;
                    XLSExporter.Write(fullPath, "Languages",
                                      new List <string>(LanguageHandlerEditor.LoadLanguageFile(null, true).Keys), LanguageHandlerEditor.LoadAllLanguageFiles());

                    Debug.Log("Exported XLS file to " + fullPath);
                    this.Close();
                }
                else
                {
                    Debug.LogError("BulkUpdateWindow: Unsupported export format!");
                }
            }
        }
        void ExportToXLS(string chosenExportFolder)
        {
            string name = chosenCulture.englishName + " - " + chosenCulture.languageCode + xlsFileEnding;

            XLSExporter.Write(chosenExportFolder + "/" + name, chosenCulture.englishName,
                              LanguageHandlerEditor.LoadLanguageFile(chosenCulture.languageCode, false));
        }
        public void CreateWorkbookFromMultipleDictsWithNullKeys_ExpectedException()
        {
            var dictionaries = new Dictionary <string, Dictionary <string, string> >();

            dictionaries.Add("en", testData);
            Assert.That(() => XLSExporter.CreateWorkbookFromMultipleDictionaries("MySheet", null, dictionaries), Throws.ArgumentNullException);
        }
        public void CreateWorkbookFromMultipleDictsWithNullKeys_ExpectedException()
        {
            var dictionaries = new Dictionary <string, Dictionary <string, string> >();

            dictionaries.Add("en", testData);
            XLSExporter.CreateWorkbookFromMultipleDictionaries("MySheet", null, dictionaries);
        }
        public void CreateWorkbookFromMultipleDictsWithNullSheetName_ExpectedException()
        {
            var dictionaries = new Dictionary <string, Dictionary <string, string> >();

            dictionaries.Add("en", testData);
            XLSExporter.CreateWorkbookFromMultipleDictionaries(null, new List <string>(), dictionaries);
        }
Пример #6
0
        void UpdateFromXLS(string chosenUpdateFile)
        {
            var values = XLSExporter.Read(chosenUpdateFile);

            LanguageHandlerEditor.UpdateLanguageFile(chosenCulture.languageCode, values);

            if (parentWindow.translateLanguageWindow != null)
            {
                parentWindow.translateLanguageWindow.ReloadLanguage();
            }
        }
        public void CreateWorkbookFromDict()
        {
            var workbook = XLSExporter.CreateWorkbookFromDictionary("MySheet", testData);

            Assert.AreEqual(1, workbook.NumberOfSheets);
            var sheet = workbook.GetSheetAt(0);

            Assert.AreEqual("MySheet", sheet.SheetName);
            Assert.AreEqual("TestKey", sheet.GetRow(0).GetCell(0).StringCellValue);
            Assert.AreEqual("TestValue", sheet.GetRow(0).GetCell(1).StringCellValue);
            Assert.AreEqual("TestKey2", sheet.GetRow(1).GetCell(0).StringCellValue);
            Assert.AreEqual("TestValue2", sheet.GetRow(1).GetCell(1).StringCellValue);
        }
        void UpdateFromXLS(string chosenUpdateFile)
        {
            var values = XLSExporter.Read(chosenUpdateFile);

            UpdateLanguageFile(values);

            /*
             * if (parentWindow.translateLanguageWindow != null)
             * {
             *  parentWindow.translateLanguageWindow.ReloadLanguage();
             * }
             */
        }
Пример #9
0
        void ImportFromXLS(string chosenImportFile)
        {
            List <List <string> > values = XLSExporter.Read(chosenImportFile);

            if (chosenCulture == null)
            {
                Debug.LogError("The language: " + chosenCulture.englishName + " could not be created");
                this.Close();
                return;
            }
            LanguageHandlerEditor.CreateNewLanguage(chosenCulture.languageCode, values);

            if (creationDelegate != null)
            {
                creationDelegate();
                creationDelegate = null;
            }
        }
Пример #10
0
        void ShowImportGUI()
        {
            if (GUILayout.Button("Import"))
            {
                if (availableFileFormats[chosenFileFormat] == csvFileEnding)
                {
                    string file = EditorUtility.OpenFilePanel("Select CSV file.", "", "");
                    if (file != null && file != "")
                    {
                        var values = CSVParser.Read(file, CSVParser.GetDelimiter(delimiter));
                        if (values.Count > 0)
                        {
                            LanguageHandlerEditor.BulkUpdateLanguageFiles(values);
                        }
                    }
                    this.Close();
                }
                else if (availableFileFormats[chosenFileFormat] == xlsFileEnding)
                {
                    string file = EditorUtility.OpenFilePanel("Select XLS file.", "", "");
                    if (file != null && file != "")
                    {
                        var values = XLSExporter.Read(file);
                        if (values.Count > 0)
                        {
                            LanguageHandlerEditor.BulkUpdateLanguageFiles(values);
                        }
                    }
                    this.Close();
                }
                else
                {
                    Debug.LogError("BulkUpdateWindow: Unsupported import format!");
                }

                if (parentWindow.translateLanguageWindow != null)
                {
                    parentWindow.translateLanguageWindow.ReloadLanguage();
                }
            }
        }
        public void CreateWorkbookFromMultipleDicts()
        {
            var dictionaries = new Dictionary <string, Dictionary <string, string> >();

            dictionaries.Add("en", testData);
            dictionaries.Add("sv", testData);
            var workbook = XLSExporter.CreateWorkbookFromMultipleDictionaries("MySheet", new List <string>(testData.Keys), dictionaries);

            Assert.AreEqual(1, workbook.NumberOfSheets);

            var sheet = workbook.GetSheetAt(0);

            Assert.AreEqual("MySheet", sheet.SheetName);
            Assert.AreEqual(string.Empty, sheet.GetRow(0).GetCell(0).StringCellValue);
            Assert.AreEqual("en", sheet.GetRow(0).GetCell(1).StringCellValue);
            Assert.AreEqual("sv", sheet.GetRow(0).GetCell(2).StringCellValue);
            Assert.AreEqual("TestKey", sheet.GetRow(1).GetCell(0).StringCellValue);
            Assert.AreEqual("TestKey2", sheet.GetRow(2).GetCell(0).StringCellValue);
            Assert.AreEqual("TestValue", sheet.GetRow(1).GetCell(1).StringCellValue);
            Assert.AreEqual("TestValue", sheet.GetRow(1).GetCell(2).StringCellValue);
            Assert.AreEqual("TestValue2", sheet.GetRow(2).GetCell(1).StringCellValue);
            Assert.AreEqual("TestValue2", sheet.GetRow(2).GetCell(2).StringCellValue);
        }
Пример #12
0
 public void CreateWorkbookFromDictWithNullSheetName_ExpectedException()
 {
     Assert.That(() => XLSExporter.CreateWorkbookFromDictionary(null, testData), Throws.ArgumentNullException);
 }
Пример #13
0
 public void CreateWorkbookFromMultipleDictsWithNullValues_ExpectedException()
 {
     Assert.That(() => XLSExporter.CreateWorkbookFromMultipleDictionaries("MySheet", new List <string>(), null), Throws.ArgumentNullException);
 }
 public void CreateWorkbookFromDictWithNullSheetName_ExpectedException()
 {
     XLSExporter.CreateWorkbookFromDictionary(null, testData);
 }
 public void CreateWorkbookFromDictWithNullData_ExpectedException()
 {
     XLSExporter.CreateWorkbookFromDictionary("MySheet", null);
 }
Пример #16
0
 public void CreateWorkbookFromDictWithNullData_ExpectedException()
 {
     Assert.That(() => XLSExporter.CreateWorkbookFromDictionary("MySheet", null), Throws.ArgumentNullException);
 }
 public void CreateWorkbookFromMultipleDictsWithNullValues_ExpectedException()
 {
     XLSExporter.CreateWorkbookFromMultipleDictionaries("MySheet", new List <string>(), null);
 }