void CreateCollection()
        {
            var assetDirectory = EditorUtility.SaveFolderPanel("Create Table Collection", "Assets/", "");

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

            LocalizationTableCollection createdCollection = null;

            if (m_CollectionTypePopup.value == typeof(StringTableCollection))
            {
                createdCollection = LocalizationEditorSettings.CreateStringTableCollection(m_TableCollectionName.value, assetDirectory, GetSelectedLocales());
            }
            if (m_CollectionTypePopup.value == typeof(AssetTableCollection))
            {
                createdCollection = LocalizationEditorSettings.CreateAssetTableCollection(m_TableCollectionName.value, assetDirectory, GetSelectedLocales());
            }

            // Select the root asset and open the table editor window.
            Selection.activeObject = createdCollection;
            LocalizationTablesWindow.ShowWindow(createdCollection);
            InitializeTableName();
        }
Beispiel #2
0
        static void ImportFileNode(IFile file, LocaleIdentifier source, LocaleIdentifier target, ImportOptions importOptions)
        {
            // Find the string table and collection for this file
            var collection = FindProjectCollection(file);

            // Import translation units which have no groups.
            INoteCollection extraNodes = file;

            if (file.TranslationUnitCount > 0)
            {
                if (collection == null)
                {
                    var dir = importOptions.NewCollectionDirectory;
                    if (string.IsNullOrEmpty(dir))
                    {
                        dir = EditorUtility.SaveFolderPanel($"Create new String Table Collection {file.Id}", "Assets", file.Id);
                    }

                    if (!string.IsNullOrEmpty(dir))
                    {
                        var newCollection = LocalizationEditorSettings.CreateStringTableCollection(file.Id, dir);
                        extraNodes = null;
                        ImportFileIntoCollection(newCollection, file, source, target, importOptions);
                    }
                }
                else
                {
                    extraNodes = null;
                    ImportFileIntoCollection(collection, file, source, target, importOptions);
                }
            }

            for (int i = 0; i < file.GroupCount; ++i)
            {
                var group           = file.GetGroup(i);
                var groupCollection = FindProjectCollection(group) ?? collection;
                if (groupCollection == null)
                {
                    // Use the provided directory otherwise ask the user to provide one
                    var dir = importOptions.NewCollectionDirectory;
                    if (string.IsNullOrEmpty(dir))
                    {
                        dir = EditorUtility.SaveFolderPanel($"Create new String Table Collection {file.Id}", "Assets", file.Id);
                        if (string.IsNullOrEmpty(dir))
                        {
                            continue;
                        }
                    }
                    var collectionName = string.IsNullOrEmpty(group.Name) ? group.Id : group.Name;
                    groupCollection = LocalizationEditorSettings.CreateStringTableCollection(collectionName, dir);
                }

                ImportGroupIntoCollection(groupCollection, group, extraNodes, source, target, importOptions);
            }
        }