Esempio n. 1
0
    private void SelectAConfig()
    {
        EditorGUILayout.LabelField("Select a config");
        var knownConfigNames = new List <string>();
        int selectedIndex    = _allKnownConfigurations.Count > 0 ? 1 : 0;

        knownConfigNames.Add("No Config");

        foreach (TranslationConfigurationSO so in _allKnownConfigurations)
        {
            knownConfigNames.Add("Group:" + so.translation_set_group);
        }

        if (selectedConfig != null)
        {
            selectedIndex = knownConfigNames.IndexOf("Group:" + selectedConfig.translation_set_group);
        }

        int newIndex = EditorGUILayout.Popup(selectedIndex, knownConfigNames.ToArray());

        if (newIndex != 0)
        {
            selectedConfig = _allKnownConfigurations[newIndex - 1];
        }
        else
        {
            selectedConfig = null;
        }
    }
Esempio n. 2
0
    public override void OnInspectorGUI()
    {
        TranslationConfigurationSO so = (TranslationConfigurationSO)target;

        DrawDefaultInspector();
        if (GUILayout.Button("Upload current set"))
        {
            var languageCodeList = new List <string> {
                so.sourceLanguage.code
            };
            so.destinationLanguages.ForEach((TransfluentLanguage lang) => { languageCodeList.Add(lang.code); });

            DownloadAllGameTranslations.uploadTranslationSet(languageCodeList, so.translation_set_group);
        }
        if (GUILayout.Button("Download known translations"))
        {
            if (EditorUtility.DisplayDialog("Downloading", "Downloading will overwrite any local changes to existing keys do you want to proceed?", "OK", "Cancel / Let me upload first"))
            {
                var languageCodeList = new List <string> {
                    so.sourceLanguage.code
                };
                so.destinationLanguages.ForEach((TransfluentLanguage lang) => { languageCodeList.Add(lang.code); });
                DownloadAllGameTranslations.downloadTranslationSetsFromLanguageCodeList(languageCodeList, so.translation_set_group);
            }
        }
    }
Esempio n. 3
0
        public void doTranslation(TranslationConfigurationSO selectedConfig)
        {
            List <int>         destLanguageIDs = new List <int>();
            GameTranslationSet set             = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(selectedConfig.sourceLanguage.code);
            var           keysToTranslate      = set.getGroup(selectedConfig.translation_set_group).getDictionaryCopy();
            List <string> textsToTranslate     = new List <string>(keysToTranslate.Keys);

            //save all of our keys before requesting to transalate them, otherwise we can get errors
            var uploadAll = new SaveSetOfKeys(selectedConfig.sourceLanguage.id,
                                              keysToTranslate,
                                              selectedConfig.translation_set_group
                                              );

            doCall(uploadAll);

            selectedConfig.destinationLanguages.ForEach((TransfluentLanguage lang) => { destLanguageIDs.Add(lang.id); });
            Stopwatch sw = new Stopwatch();

            sw.Start();
            var translate = new OrderTranslation(selectedConfig.sourceLanguage.id,
                                                 target_languages: destLanguageIDs.ToArray(),
                                                 texts: textsToTranslate.ToArray(),
                                                 level: selectedConfig.QualityToRequest,
                                                 group_id: selectedConfig.translation_set_group,
                                                 comment: "Do not replace any strings that look like {0} or {1} as they are a part of formatted text -- ie Hello {0} will turn into Hello Alex or some other string "
                                                 );

            doCall(translate);
            Debug.Log("full request time:" + sw.Elapsed);
        }
Esempio n. 4
0
    private void saveCurrentConfig()
    {
        TranslationConfigurationSO config = getOrCreateGameTranslationConfig(groupidDisplayed);

        config.translation_set_group = groupidDisplayed;
        EditorUtility.SetDirty(config);
        AssetDatabase.SaveAssets();
    }
Esempio n. 5
0
    public static TranslationConfigurationSO getOrCreateGameTranslationConfig(string groupid)
    {
        string fileName = ResourceLoadFacade.TranslationConfigurationSOFileNameFromGroupID(groupid);
        TranslationConfigurationSO config =
            ResourceLoadFacade.LoadConfigGroup(groupid) ??
            ResourceCreator.CreateSO <TranslationConfigurationSO>(fileName);

        config.translation_set_group = groupid;
        return(config);
    }
        public void addToDB(string key, string value)
        {
            string currentGroup = _translationDB.groupBeingShown;
            TranslationConfigurationSO  config = ResourceLoadFacade.LoadConfigGroup(_translationDB.groupBeingShown);
            Dictionary <string, string> translationDictionary = _translationDB.allKnownTranslations;
            GameTranslationSet          gameTranslationSet    =
                GameTranslationGetter.GetTranslaitonSetFromLanguageCode(config.sourceLanguage.code);

            bool exists = translationDictionary.ContainsKey(key);

            if (!exists)
            {
                translationDictionary.Add(key, key);
            }

            gameTranslationSet.mergeInSet(currentGroup, translationDictionary);
            //_translationDB.allKnownTranslations.Add(key,value);
        }
Esempio n. 7
0
    private void createANewConfig()
    {
        GUILayout.Label("Group Id:");
        groupidDisplayed = GUILayout.TextField(groupidDisplayed);
        if (GUILayout.Button("Create a new Config"))
        {
            if (groupidExists(groupidDisplayed))
            {
                EditorUtility.DisplayDialog("Error", "Group ID Exists, cannot create again", "OK", "");
                return;
            }
            TranslationConfigurationSO config = getOrCreateGameTranslationConfig(groupidDisplayed);
            saveCurrentConfig();

            _allKnownConfigurations.Add(config);

            selectedConfig = config;
        }
    }
            public static void setKeyInDefaultLanguageDB(string key, string value, string groupid = "")
            {
                //Debug.LogWarning("Make sure to set language to game source language before saving a new translation key");
                Dictionary <string, string> translationDictionary =
                    TranslationUtility.getUtilityInstanceForDebugging().allKnownTranslations;
                TranslationConfigurationSO config = ResourceLoadFacade.LoadConfigGroup(groupid);

                GameTranslationSet gameTranslationSet =
                    GameTranslationGetter.GetTranslaitonSetFromLanguageCode(config.sourceLanguage.code);

                bool exists = translationDictionary.ContainsKey(key);

                if (!exists)
                {
                    translationDictionary.Add(key, key);
                }
                translationDictionary[key] = value;                 //find a way to make sure the the SO gets set dirty?

                gameTranslationSet.mergeInSet(groupid, translationDictionary);
                //EditorUtility.SetnDirty(TransfluentUtility.getUtilityInstanceForDebugging());
            }
        public void doTranslation(TranslationConfigurationSO selectedConfig)
        {
            List<int> destLanguageIDs = new List<int>();
            GameTranslationSet set = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(selectedConfig.sourceLanguage.code);
            var keysToTranslate = set.getGroup(selectedConfig.translation_set_group).getDictionaryCopy();
            List<string> textsToTranslate = new List<string>(keysToTranslate.Keys);

            //save all of our keys before requesting to transalate them, otherwise we can get errors
            var uploadAll = new SaveSetOfKeys(selectedConfig.sourceLanguage.id,
                keysToTranslate,
                selectedConfig.translation_set_group
                );
            doCall(uploadAll);

            selectedConfig.destinationLanguages.ForEach((TransfluentLanguage lang) => { destLanguageIDs.Add(lang.id); });
            Stopwatch sw = new Stopwatch();
            sw.Start();
            var translate = new OrderTranslation(selectedConfig.sourceLanguage.id,
                    target_languages: destLanguageIDs.ToArray(),
                    texts: textsToTranslate.ToArray(),
                    level: selectedConfig.QualityToRequest,
                    group_id: selectedConfig.translation_set_group,
                    comment: "Do not replace any strings that look like {0} or {1} as they are a part of formatted text -- ie Hello {0} will turn into Hello Alex or some other string "
                    );
            doCall(translate);
            Debug.Log("full request time:" + sw.Elapsed);
        }
Esempio n. 10
0
    public void DrawContent()
    {
        if (!GetLanguagesGUI())
        {
            return;
        }
        if (_allKnownConfigurations.Count == 0)
        {
            createANewConfig();
            if (_allKnownConfigurations.Count == 0)
            {
                return;
            }
        }

        advancedOptions = EditorGUILayout.Toggle("Advanced Options", advancedOptions);
        if (advancedOptions)
        {
            showAllLanguages = EditorGUILayout.Toggle("Show all langauges, not just simplified list", showAllLanguages);
            SelectAConfig();
            createANewConfig();
        }
        else
        {
            selectedConfig = getOrCreateGameTranslationConfig("");
        }

        if (selectedConfig == null)
        {
            return;
        }
        DisplaySelectedTranslationConfiguration(selectedConfig);

        GUILayout.Space(30);

        if (GUILayout.Button("SHOW MISSING TRANSLATION COUNTS"))
        {
            if (_estimate == null)
            {
                _estimate = new TranslationEstimate(_mediator);
            }
            StringBuilder sb = new StringBuilder();
            foreach (var dest in selectedConfig.destinationLanguages)
            {
                int missing = _estimate.numberOfMissingTranslationsBetweenLanguages(selectedConfig.sourceLanguage,
                                                                                    dest, selectedConfig.translation_set_group);
                if (missing > 0)
                {
                    sb.AppendFormat("Language {0} is missing {1} translations\n", dest.name, missing);
                }
            }
            EditorUtility.DisplayDialog("MISSING", "Missing this many translations:\n" + sb.ToString(), "OK");
        }

        GUILayout.Space(30);
        GUILayout.Label("Account options:");

        if (!userHasSetCredentials())
        {
            GUILayout.Label("Log in to translate your text as well as upload and download your local translations");
            ShowLoginFields();
            //return;
        }
        else
        {
            if (GUILayout.Button("LOG OUT OF ACCOUNT"))
            {
                _mediator.setUsernamePassword("", "");
            }
        }
        ShowUploadDownload();

        DoTranslation();
    }
    public void DrawContent()
    {
        if(!GetLanguagesGUI())
        {
            return;
        }
        if(_allKnownConfigurations.Count == 0)
        {
            createANewConfig();
            if(_allKnownConfigurations.Count == 0) return;
        }

        advancedOptions = EditorGUILayout.Toggle("Advanced Options", advancedOptions);
        if(advancedOptions)
        {
            showAllLanguages = EditorGUILayout.Toggle("Show all langauges, not just simplified list", showAllLanguages);
            SelectAConfig();
            createANewConfig();
        }
        else
        {
            selectedConfig = getOrCreateGameTranslationConfig("");
        }

        if(selectedConfig == null)
        {
            return;
        }
        DisplaySelectedTranslationConfiguration(selectedConfig);

        GUILayout.Space(30);

        if(GUILayout.Button("SHOW MISSING TRANSLATION COUNTS"))
        {
            if(_estimate == null)
            {
                _estimate = new TranslationEstimate(_mediator);
            }
            StringBuilder sb = new StringBuilder();
            foreach(var dest in selectedConfig.destinationLanguages)
            {
                int missing = _estimate.numberOfMissingTranslationsBetweenLanguages(selectedConfig.sourceLanguage,
                    dest, selectedConfig.translation_set_group);
                if(missing > 0)
                {
                    sb.AppendFormat("Language {0} is missing {1} translations\n", dest.name, missing);
                }
            }
            EditorUtility.DisplayDialog("MISSING", "Missing this many translations:\n" + sb.ToString(), "OK");
        }

        GUILayout.Space(30);
        GUILayout.Label("Account options:");

        if(!userHasSetCredentials())
        {
            GUILayout.Label("Log in to translate your text as well as upload and download your local translations");
            ShowLoginFields();
            //return;
        }
        else
        {
            if(GUILayout.Button("LOG OUT OF ACCOUNT"))
            {
                _mediator.setUsernamePassword("", "");
            }
        }
        ShowUploadDownload();

        DoTranslation();
    }
Esempio n. 12
0
        //public static event Action OnLanguageChanged;

        public static ITranslationUtilityInstance createNewInstance(string destinationLanguageCode = "", string group = "")
        {
            if (_LanguageList == null)
            {
                _LanguageList = ResourceLoadFacade.getLanguageList();
            }

            if (_LanguageList == null)
            {
                Debug.LogError("Could not load new language list");
                return(null);
            }
            bool enableCapture = false;

#if UNITY_EDITOR
            if (Application.isEditor)
            {
                enableCapture = getCaptureMode();
            }
#endif //UNTIY_EDITOR

            TransfluentLanguage dest = _LanguageList.getLangaugeByCode(destinationLanguageCode);
            if (dest == null)
            {
                TranslationConfigurationSO defaultConfigInfo = ResourceLoadFacade.LoadConfigGroup(group);
                string newDestinationLanguageCode            = defaultConfigInfo.sourceLanguage.code;

                /*
                 * if (string.IsNullOrEmpty(destinationLanguageCode))
                 * {
                 *      Debug.Log("Using default destination language code, as was given an empty language code");
                 * }
                 * else
                 *      Debug.Log("Could not load destination language code:" + destinationLanguageCode + " so falling back to source game language code:" + destinationLanguageCode);
                 */
                destinationLanguageCode = newDestinationLanguageCode;

                dest = _LanguageList.getLangaugeByCode(destinationLanguageCode);
                //dest = _LanguageList.getLangaugeByCode
            }
            GameTranslationSet          destLangDB = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(destinationLanguageCode);
            Dictionary <string, string> keysInLanguageForGroupSpecified = destLangDB != null
                                ? destLangDB.getGroup(group).getDictionaryCopy()
                                : new Dictionary <string, string>();

#if UNITY_EDITOR
            EditorUtility.SetDirty(destLangDB);
#endif

            var newTranslfuentUtilityInstance = new TranslationUtilityInstance
            {
                allKnownTranslations = keysInLanguageForGroupSpecified,
                destinationLanguage  = dest,
                groupBeingShown      = group,
            };
            if (enableCapture)
            {
                newTranslfuentUtilityInstance = new AutoCaptureTranslationUtiliityInstance()
                {
                    allKnownTranslations = keysInLanguageForGroupSpecified,
                    destinationLanguage  = dest,
                    groupBeingShown      = group,
                    doCapture            = enableCapture,
                    coreTransltionSet    = destLangDB,
                };
            }
            return(newTranslfuentUtilityInstance);
        }
 public OrderFlowAsync(TranslationConfigurationSO selectedConfig, string token)
 {
     _selectedConfig = selectedConfig;
     _token = token;
 }
	// Use this for initialization
	private void Start()
	{
		config = ResourceLoadFacade.LoadConfigGroup("");
		populateKnownTranslationsInGroup();
		TranslationUtility.changeStaticInstanceConfig("xx-xx");
	}
Esempio n. 15
0
        public void presentEstimateAndMakeOrder(TranslationConfigurationSO selectedConfig)
        {
            //var languageEstimates = new Dictionary<TransfluentLanguage, EstimateTranslationCostVO.Price>();
            if (_asyncFlow != null)
            {
                if (!_asyncFlow.orderIsDone())
                {
                    if (GUILayout.Button("ORDERING..."))
                    {
                    }
                    ;
                    return;
                }
            }

            EstimateTranslationCostVO.Price costPerWordFromSourceLanguage = null;
            //Debug.Log("ASYNC FLOW:"+(_asyncFlow != null).ToString() + " isdone:"+(_asyncFlow != null && _asyncFlow.orderIsDone()));
            if (GUILayout.Button("Translate"))
            {
                doAuth();
                if (string.IsNullOrEmpty(_token))
                {
                    return;
                }

                string group     = selectedConfig.translation_set_group;
                var    sourceSet = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(selectedConfig.sourceLanguage.code);
                if (sourceSet == null || sourceSet.getGroup(group) == null)
                {
                    EditorUtility.DisplayDialog("ERROR", "No messages in group", "OK");
                    return;
                }

                StringBuilder simpleEstimateString = new StringBuilder();

                //find the first language that returns a result for "hello" and use that for the cost
                foreach (TransfluentLanguage lang in selectedConfig.destinationLanguages)
                {
                    try
                    {
                        //TODO: other currencies
                        var call = new EstimateTranslationCost("hello", selectedConfig.sourceLanguage.id,
                                                               lang.id, quality: selectedConfig.QualityToRequest);
                        var callResult = doCall(call);
                        EstimateTranslationCostVO estimate = call.Parse(callResult.text);
                        //string printedEstimate = string.Format("Language:{0} cost per word: {1} {2}\n", lang.name, estimate.price.amount, estimate.price.currency);
                        costPerWordFromSourceLanguage = estimate.price;
                        //simpleEstimateString.Append(printedEstimate);
                        //Debug.Log("Estimate:" + JsonWriter.Serialize(estimate));
                        break;
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("Error estimating prices: " + e);
                    }
                }

                var  toTranslate        = sourceSet.getGroup(group).getDictionaryCopy();
                long sourceSetWordCount = 0;
                foreach (KeyValuePair <string, string> kvp in toTranslate)
                {
                    sourceSetWordCount += kvp.Value.Split(' ').Length;
                }

                //var knownKeys = sourceSet.getPretranslatedKeys(sourceSet.getAllKeys(), selectedConfig.translation_set_group);
                //var sourceDictionary = sourceSet.getGroup().getDictionaryCopy();
                foreach (TransfluentLanguage lang in selectedConfig.destinationLanguages)
                {
                    if (lang.code == "xx-xx")
                    {
                        simpleEstimateString.AppendFormat("language: {0} est cost: {1}\n", lang.name, "FREE!");
                        continue;
                    }
                    var  set = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(lang.code);
                    long alreadyTranslatedWordCount = 0;

                    if (set != null)
                    {
                        var destKeys = set.getGroup(group).getDictionaryCopy();
                        foreach (KeyValuePair <string, string> kvp in toTranslate)
                        {
                            if (!destKeys.ContainsKey(kvp.Key))
                            {
                                alreadyTranslatedWordCount += kvp.Value.Split(' ').Length;
                            }
                        }
                    }

                    var   oneWordPrice         = costPerWordFromSourceLanguage;
                    float costPerWord          = float.Parse(oneWordPrice.amount);
                    long  toTranslateWordcount = sourceSetWordCount - alreadyTranslatedWordCount;
                    if (toTranslateWordcount < 0)
                    {
                        toTranslateWordcount *= -1;
                    }

                    float totalCost = costPerWord * toTranslateWordcount;

                    simpleEstimateString.AppendFormat("language: {0} est cost: {1}\n", lang.name, totalCost);
                    //	lang.name, totalCost, oneWordPrice.currency, costPerWord, toTranslateWordcount);
                    //simpleEstimateString.AppendFormat("language name: {0} total cost: {1} {2} \n\tCost per word:{3} total words to translate:{4} ",
                    //	lang.name, totalCost, oneWordPrice.currency, costPerWord, toTranslateWordcount);
                }

                Debug.Log("Estimated prices");

                if (EditorUtility.DisplayDialog("Estimates", "Estimated cost(only additions counted in estimate):\n" + simpleEstimateString, "OK", "Cancel"))
                {
                    _asyncFlow = new OrderFlowAsync(selectedConfig, _token);
                    _asyncFlow.startFlow();
                    //doTranslation(selectedConfig);
                }
            }
        }
Esempio n. 16
0
 public OrderFlowAsync(TranslationConfigurationSO selectedConfig, string token)
 {
     _selectedConfig = selectedConfig;
     _token          = token;
 }
Esempio n. 17
0
        public void doTranslation2(TranslationConfigurationSO selectedConfig)
        {
            OrderFlowAsync orderFlow = new OrderFlowAsync(selectedConfig, _token);

            orderFlow.startFlow();
        }
 public void doTranslation2(TranslationConfigurationSO selectedConfig)
 {
     OrderFlowAsync orderFlow = new OrderFlowAsync(selectedConfig, _token);
     orderFlow.startFlow();
 }
        public void presentEstimateAndMakeOrder(TranslationConfigurationSO selectedConfig)
        {
            //var languageEstimates = new Dictionary<TransfluentLanguage, EstimateTranslationCostVO.Price>();
            if(_asyncFlow != null)
            {
                if(!_asyncFlow.orderIsDone())
                {
                    if(GUILayout.Button("ORDERING..."))
                    {
                    };
                    return;
                }
            }

            EstimateTranslationCostVO.Price costPerWordFromSourceLanguage = null;
            //Debug.Log("ASYNC FLOW:"+(_asyncFlow != null).ToString() + " isdone:"+(_asyncFlow != null && _asyncFlow.orderIsDone()));
            if(GUILayout.Button("Translate"))
            {
                doAuth();
                if(string.IsNullOrEmpty(_token))
                {
                    return;
                }

                string group = selectedConfig.translation_set_group;
                var sourceSet = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(selectedConfig.sourceLanguage.code);
                if(sourceSet == null || sourceSet.getGroup(group) == null)
                {
                    EditorUtility.DisplayDialog("ERROR", "No messages in group", "OK");
                    return;
                }

                StringBuilder simpleEstimateString = new StringBuilder();

                //find the first language that returns a result for "hello" and use that for the cost
                foreach(TransfluentLanguage lang in selectedConfig.destinationLanguages)
                {
                    try
                    {
                        //TODO: other currencies
                        var call = new EstimateTranslationCost("hello", selectedConfig.sourceLanguage.id,
                                                            lang.id, quality: selectedConfig.QualityToRequest);
                        var callResult = doCall(call);
                        EstimateTranslationCostVO estimate = call.Parse(callResult.text);
                        //string printedEstimate = string.Format("Language:{0} cost per word: {1} {2}\n", lang.name, estimate.price.amount, estimate.price.currency);
                        costPerWordFromSourceLanguage = estimate.price;
                        //simpleEstimateString.Append(printedEstimate);
                        //Debug.Log("Estimate:" + JsonWriter.Serialize(estimate));
                        break;
                    }
                    catch(Exception e)
                    {
                        Debug.LogError("Error estimating prices: "+e);
                    }
                }

                var toTranslate = sourceSet.getGroup(group).getDictionaryCopy();
                long sourceSetWordCount = 0;
                foreach(KeyValuePair<string, string> kvp in toTranslate)
                {
                    sourceSetWordCount += kvp.Value.Split(' ').Length;
                }

                //var knownKeys = sourceSet.getPretranslatedKeys(sourceSet.getAllKeys(), selectedConfig.translation_set_group);
                //var sourceDictionary = sourceSet.getGroup().getDictionaryCopy();
                foreach(TransfluentLanguage lang in selectedConfig.destinationLanguages)
                {
                    if(lang.code == "xx-xx")
                    {
                        simpleEstimateString.AppendFormat("language: {0} est cost: {1}\n", lang.name, "FREE!");
                        continue;
                    }
                    var set = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(lang.code);
                    long alreadyTranslatedWordCount = 0;

                    if(set != null)
                    {
                        var destKeys = set.getGroup(group).getDictionaryCopy();
                        foreach(KeyValuePair<string, string> kvp in toTranslate)
                        {
                            if(!destKeys.ContainsKey(kvp.Key))
                                alreadyTranslatedWordCount += kvp.Value.Split(' ').Length;
                        }
                    }

                    var oneWordPrice = costPerWordFromSourceLanguage;
                    float costPerWord = float.Parse(oneWordPrice.amount);
                    long toTranslateWordcount = sourceSetWordCount - alreadyTranslatedWordCount;
                    if(toTranslateWordcount < 0) toTranslateWordcount *= -1;

                    float totalCost = costPerWord * toTranslateWordcount;

                    simpleEstimateString.AppendFormat("language: {0} est cost: {1}\n", lang.name, totalCost);
                    //	lang.name, totalCost, oneWordPrice.currency, costPerWord, toTranslateWordcount);
                    //simpleEstimateString.AppendFormat("language name: {0} total cost: {1} {2} \n\tCost per word:{3} total words to translate:{4} ",
                    //	lang.name, totalCost, oneWordPrice.currency, costPerWord, toTranslateWordcount);
                }

                Debug.Log("Estimated prices");

                if(EditorUtility.DisplayDialog("Estimates", "Estimated cost(only additions counted in estimate):\n" + simpleEstimateString, "OK", "Cancel"))
                {
                    _asyncFlow = new OrderFlowAsync(selectedConfig, _token);
                    _asyncFlow.startFlow();
                    //doTranslation(selectedConfig);
                }
            }
        }
Esempio n. 20
0
    private void DisplaySelectedTranslationConfiguration(TranslationConfigurationSO so)
    {
        List <string> knownLanguageDisplayNames = showAllLanguages ?
                                                  _languages.getListOfIdentifiersFromLanguageList() :
                                                  _languages.getSimplifiedListOfIdentifiersFromLanguageList();

        int sourceLanguageIndex = knownLanguageDisplayNames.IndexOf(so.sourceLanguage.name);

        if (sourceLanguageIndex < 0)
        {
            sourceLanguageIndex = 0;
        }
        EditorGUILayout.LabelField(string.Format("group identifier:{0}", so.translation_set_group));
        EditorGUILayout.LabelField(string.Format("source language:{0}", so.sourceLanguage.name));

        sourceLanguageIndex = EditorGUILayout.Popup(sourceLanguageIndex, knownLanguageDisplayNames.ToArray());
        if (GUILayout.Button("SET Source to this language" + knownLanguageDisplayNames[sourceLanguageIndex]))
        {
            so.sourceLanguage = _languages.getLangaugeByName(knownLanguageDisplayNames[sourceLanguageIndex]);
        }

        EditorGUILayout.LabelField("destination language(s):");
        TransfluentLanguage removeThisLang = null;

        foreach (TransfluentLanguage lang in so.destinationLanguages)
        {
            GUILayout.Space(10);
            EditorGUILayout.LabelField("destination language:" + lang.name);
            if (GUILayout.Button("Remove", GUILayout.Width(100)))
            {
                removeThisLang = lang;
            }
        }
        if (removeThisLang != null)
        {
            so.destinationLanguages.Remove(removeThisLang);
            saveCurrentConfig();
        }

        GUILayout.Space(30);

        newDestinationLanguageIndex = EditorGUILayout.Popup(newDestinationLanguageIndex, knownLanguageDisplayNames.ToArray());

        if (GUILayout.Button("Create a new Destination Language"))
        {
            TransfluentLanguage lang = _languages.getLangaugeByName(knownLanguageDisplayNames[newDestinationLanguageIndex]);
            if (so.sourceLanguage.id == lang.id)
            {
                EditorUtility.DisplayDialog("Error", "Cannot have the source language be the destination language", "OK", "");
                return;
            }
            foreach (TransfluentLanguage exists in so.destinationLanguages)
            {
                if (exists.id != lang.id)
                {
                    continue;
                }
                EditorUtility.DisplayDialog("Error", "You already have added this language: " + lang.name, "OK", "");
                return;
            }

            so.destinationLanguages.Add(lang);

            GUILayout.Space(10);

            saveCurrentConfig();
        }
        GUILayout.Space(10);
        var translationQualityStrings = new List <string>()
        {
            OrderTranslation.TranslationQuality.NATIVE_SPEAKER.ToString(),
            OrderTranslation.TranslationQuality.PROFESSIONAL_TRANSLATOR.ToString(),
            OrderTranslation.TranslationQuality.PAIR_OF_TRANSLATORS.ToString(),
        };
        int currentIndex = translationQualityStrings.IndexOf(so.QualityToRequest.ToString());
        int newIndex     = EditorGUILayout.Popup("Desired Translation Quality:", currentIndex, translationQualityStrings.ToArray());

        if (newIndex != currentIndex)
        {
            so.QualityToRequest = (OrderTranslation.TranslationQuality)newIndex + 1;
        }
    }
Esempio n. 21
0
 // Use this for initialization
 private void Start()
 {
     config = ResourceLoadFacade.LoadConfigGroup("");
     populateKnownTranslationsInGroup();
     TranslationUtility.changeStaticInstanceConfig("xx-xx");
 }
    private void DisplaySelectedTranslationConfiguration(TranslationConfigurationSO so)
    {
        List<string> knownLanguageDisplayNames = showAllLanguages ?
            _languages.getListOfIdentifiersFromLanguageList() :
            _languages.getSimplifiedListOfIdentifiersFromLanguageList();

        int sourceLanguageIndex = knownLanguageDisplayNames.IndexOf(so.sourceLanguage.name);

        if(sourceLanguageIndex < 0) sourceLanguageIndex = 0;
        EditorGUILayout.LabelField(string.Format("group identifier:{0}", so.translation_set_group));
        EditorGUILayout.LabelField(string.Format("source language:{0}", so.sourceLanguage.name));

        sourceLanguageIndex = EditorGUILayout.Popup(sourceLanguageIndex, knownLanguageDisplayNames.ToArray());
        if(GUILayout.Button("SET Source to this language" + knownLanguageDisplayNames[sourceLanguageIndex]))
        {
            so.sourceLanguage = _languages.getLangaugeByName(knownLanguageDisplayNames[sourceLanguageIndex]);
        }

        EditorGUILayout.LabelField("destination language(s):");
        TransfluentLanguage removeThisLang = null;

        foreach(TransfluentLanguage lang in so.destinationLanguages)
        {
            GUILayout.Space(10);
            EditorGUILayout.LabelField("destination language:" + lang.name);
            if(GUILayout.Button("Remove", GUILayout.Width(100)))
            {
                removeThisLang = lang;
            }
        }
        if(removeThisLang != null)
        {
            so.destinationLanguages.Remove(removeThisLang);
            saveCurrentConfig();
        }

        GUILayout.Space(30);

        newDestinationLanguageIndex = EditorGUILayout.Popup(newDestinationLanguageIndex, knownLanguageDisplayNames.ToArray());

        if(GUILayout.Button("Create a new Destination Language"))
        {
            TransfluentLanguage lang = _languages.getLangaugeByName(knownLanguageDisplayNames[newDestinationLanguageIndex]);
            if(so.sourceLanguage.id == lang.id)
            {
                EditorUtility.DisplayDialog("Error", "Cannot have the source language be the destination language", "OK", "");
                return;
            }
            foreach(TransfluentLanguage exists in so.destinationLanguages)
            {
                if(exists.id != lang.id) continue;
                EditorUtility.DisplayDialog("Error", "You already have added this language: " + lang.name, "OK", "");
                return;
            }

            so.destinationLanguages.Add(lang);

            GUILayout.Space(10);

            saveCurrentConfig();
        }
        GUILayout.Space(10);
        var translationQualityStrings = new List<string>()
            {
                OrderTranslation.TranslationQuality.NATIVE_SPEAKER.ToString(),
                OrderTranslation.TranslationQuality.PROFESSIONAL_TRANSLATOR.ToString(),
                OrderTranslation.TranslationQuality.PAIR_OF_TRANSLATORS.ToString(),
            };
        int currentIndex = translationQualityStrings.IndexOf(so.QualityToRequest.ToString());
        int newIndex = EditorGUILayout.Popup("Desired Translation Quality:", currentIndex, translationQualityStrings.ToArray());
        if(newIndex != currentIndex)
        {
            so.QualityToRequest = (OrderTranslation.TranslationQuality)newIndex + 1;
        }
    }
    private void createANewConfig()
    {
        GUILayout.Label("Group Id:");
        groupidDisplayed = GUILayout.TextField(groupidDisplayed);
        if(GUILayout.Button("Create a new Config"))
        {
            if(groupidExists(groupidDisplayed))
            {
                EditorUtility.DisplayDialog("Error", "Group ID Exists, cannot create again", "OK", "");
                return;
            }
            TranslationConfigurationSO config = getOrCreateGameTranslationConfig(groupidDisplayed);
            saveCurrentConfig();

            _allKnownConfigurations.Add(config);

            selectedConfig = config;
        }
    }
    private void SelectAConfig()
    {
        EditorGUILayout.LabelField("Select a config");
        var knownConfigNames = new List<string>();
        int selectedIndex = _allKnownConfigurations.Count > 0 ? 1 : 0;
        knownConfigNames.Add("No Config");

        foreach(TranslationConfigurationSO so in _allKnownConfigurations)
        {
            knownConfigNames.Add("Group:" + so.translation_set_group);
        }

        if(selectedConfig != null)
        {
            selectedIndex = knownConfigNames.IndexOf("Group:" + selectedConfig.translation_set_group);
        }

        int newIndex = EditorGUILayout.Popup(selectedIndex, knownConfigNames.ToArray());
        if(newIndex != 0)
        {
            selectedConfig = _allKnownConfigurations[newIndex - 1];
        }
        else
        {
            selectedConfig = null;
        }
    }