Пример #1
0
        private void ProcessTranslationFile(int i, string csvText, int newTextColumn, bool ignoreEmptyCells)
        {
            string [,] csvOutput = CSVReader.SplitCsvGrid(csvText);

            int    lineID          = 0;
            string translationText = string.Empty;

            if (csvOutput.GetLength(0) <= newTextColumn)
            {
                ACDebug.LogWarning("Cannot import translation file, as it does not have enough columns - searching for column index " + newTextColumn);
                return;
            }

            for (int y = 1; y < csvOutput.GetLength(1); y++)
            {
                if (csvOutput [0, y] != null && csvOutput [0, y].Length > 0)
                {
                    lineID = -1;
                    if (int.TryParse(csvOutput [0, y], out lineID))
                    {
                        translationText = csvOutput [newTextColumn, y];
                        translationText = AddLineBreaks(translationText);

                        if (!ignoreEmptyCells || !string.IsNullOrEmpty(translationText))
                        {
                            UpdateRuntimeTranslation(lineID, i, translationText);
                        }
                    }
                    else
                    {
                        ACDebug.LogWarning("Error importing translation (ID:" + csvOutput [0, y] + ") - make sure that the CSV file is delimited by a '" + CSVReader.csvDelimiter + "' character.");
                    }
                }
            }
        }
Пример #2
0
        private void ProcessTranslationFile(int i, string csvText)
        {
            string [,] csvOutput = CSVReader.SplitCsvGrid(csvText);

            int    lineID          = 0;
            string translationText = "";
            string owner           = "";

            for (int y = 1; y < csvOutput.GetLength(1); y++)
            {
                if (csvOutput [0, y] != null && csvOutput [0, y].Length > 0)
                {
                    lineID = -1;
                    if (int.TryParse(csvOutput [0, y], out lineID))
                    {
                        translationText = csvOutput [3, y];                        //.Replace (CSVReader.csvTemp, CSVReader.csvComma);
                        string typeText = csvOutput [1, y];                        //.Replace (CSVReader.csvTemp, CSVReader.csvComma);

                        if (typeText.Contains("JournalEntry (Page "))
                        {
                            owner = typeText.Replace("JournalEntry (", "");
                            owner = owner.Replace(")", "");
                        }
                        else
                        {
                            owner = "";
                        }
                        UpdateTranslation(i, lineID, owner, AddLineBreaks(translationText));
                    }
                    else
                    {
                        ACDebug.LogWarning("Error importing translation (ID:" + csvOutput [0, y] + ") - make sure that the CSV file is delimited by a '" + CSVReader.csvDelimiter + "' character.");
                    }
                }
            }
        }