Exemple #1
0
        public static void ExportCollectionWithComments(MenuCommand command)
        {
            var collection = command.context as StringTableCollection;

            Assert.IsTrue(collection != null, "Expected StringTableCollection");
            Export(ColumnMapping.CreateDefaultMapping(true), collection);
        }
        static void AddDefaultColumns(CsvExtensionPropertyDrawerData data, bool includeComments)
        {
            var columns = ColumnMapping.CreateDefaultMapping(includeComments);

            data.m_Columns.ClearArray();
            foreach (var c in columns)
            {
                var colElement = data.m_Columns.AddArrayElement();
                colElement.managedReferenceValue = c;
            }
            data.m_Columns.serializedObject.ApplyModifiedProperties();
        }
        public static void PushProjectLocales()
        {
            // Setup the connection to Google
            var sheetServiceProvider = GetServiceProvider();
            var googleSheets         = new GoogleSheets(sheetServiceProvider);

            googleSheets.SpreadSheetId = "My spread sheet id"; // We need to provide the Spreadsheet id. This can be found in the url. See docs for further info.

            // Prepare the data we want to push.
            // You should provide your String Table Collection name here
            var tableCollection = LocalizationEditorSettings.GetStringTableCollection("My Strings");

            // CreateDefaultMapping will create a KeyColumn and a LocaleColumn for each Locale in the project.
            var columnMappings = ColumnMapping.CreateDefaultMapping();
            int mySheetId      = 123456; // This it the id of the sheet in the Google Spreadsheet. it will be in the url after `gid=`.

            // Now send the update. We can pass in an optional ProgressBarReporter so that we can see updates in the Editor.
            googleSheets.PushStringTableCollection(mySheetId, tableCollection, columnMappings, new ProgressBarReporter());
        }
        public static void PullProjectLocales()
        {
            // Setup the connection to Google
            var sheetServiceProvider = GetServiceProvider();
            var googleSheets         = new GoogleSheets(sheetServiceProvider);

            googleSheets.SpreadSheetId = "My spread sheet id"; // We need to provide the Spreadsheet id. This can be found in the url. See docs for further info.

            // You should provide your String Table Collection name here
            var tableCollection = LocalizationEditorSettings.GetStringTableCollection("My Strings");

            // CreateDefaultMapping will create a KeyColumn and a LocaleColumn for each Locale in the project.
            // This assumes that the table was created and pushed to using the same column mappings.
            var columnMappings = ColumnMapping.CreateDefaultMapping();
            int mySheetId      = 123456; // This it the id of the sheet in the Google Spreadsheet. it will be in the url after `gid=`.

            // Now pull.
            // removeMissingEntries will remove any Keys that we have in the String Table Collection that do not exist in the Pull update.
            // reporter is an optional reporter that can be used to povide feedback in the editor during the Pull.
            googleSheets.PullIntoStringTableCollection(mySheetId, tableCollection, columnMappings, removeMissingEntries: true, reporter: new ProgressBarReporter());
        }
 /// <summary>
 /// Exports all <see cref="UnityEngine.Localization.Tables.StringTable"/> in <paramref name="collection"/> using default column mappings generated through
 /// <see cref="ColumnMapping.CreateDefaultMapping(bool)"/>.
 /// </summary>
 /// <param name="writer">The target that will be populated with CSV data.</param>
 /// <param name="collection">The collection to export to CSV.</param>
 /// <param name="reporter">An optional reporter that can be used to provide feedback during export.</param>
 /// <example>
 /// This example shows how to export a <see cref="StringTableCollection"/> to a csv file.
 /// <code>
 /// using (var stream = new StreamWriter("my CSV file.csv", false, Encoding.UTF8))
 /// {
 ///     var stringTableCollection = LocalizationEditorSettings.GetStringTableCollection("My Strings");
 ///     Export(stream, stringTableCollection);
 /// }
 /// </code>
 /// </example>
 public static void Export(TextWriter writer, StringTableCollection collection, ITaskReporter reporter = null)
 {
     Export(writer, collection, ColumnMapping.CreateDefaultMapping(), reporter);
 }
 /// <summary>
 /// Import the CSV data into <paramref name="collection"/> using <paramref name="columnMappings"/> to control what data will be imported.
 /// See <seealso cref="KeyIdColumns"/> and <seealso cref="LocaleColumns"/> for further details.
 /// </summary>
 /// <param name="reader">The source of the CSV data.</param>
 /// <param name="collection">The target collection to be updated using the CSV data.</param>
 /// <param name="createUndo">Should an Undo operation be created so the changes can be undone?</param>
 /// <param name="reporter">An optional reporter that can be used to provide feedback during import.</param>
 public static void ImportInto(TextReader reader, StringTableCollection collection, bool createUndo = false, ITaskReporter reporter = null)
 {
     ImportInto(reader, collection, ColumnMapping.CreateDefaultMapping(), createUndo, reporter);
 }