Ejemplo n.º 1
0
        public static void uploadTranslationSet(List <string> languageCodes, string groupid)
        {
            TransfluentEditorWindowMediator mediator = getAuthenticatedMediator();

            if (mediator == null)
            {
                return;
            }

            foreach (string languageCode in languageCodes)
            {
                try
                {
                    GameTranslationSet set = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(languageCode);
                    GameTranslationSet.GroupOfTranslations groupData = set.getGroup(groupid);
                    TransfluentLanguage lang = ResourceLoadFacade.getLanguageList().getLangaugeByCode(languageCode);
                    if (groupData.translations.Count > 0)
                    {
                        mediator.SaveGroupToServer(groupData, lang);
                    }
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 2
0
        public void ordermytranslation()
        {
            //just queue up all the calls until first real stopping point
            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);

            _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 ",
                                                 fork: true
                                                 );

            doCall(translate, () =>
            {
                Debug.Log("ORDER DONE");
                _orderDone = true; EditorUtility.DisplayDialog("Success", "Transltion order complete!", "OK");
            });
        }
Ejemplo 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);
        }
Ejemplo n.º 4
0
        //[MenuItem("Transfluent/test get content")]
        public static void getTestContent()
        {
            var list = ResourceLoadFacade.getLanguageList();
            GameTranslationSet source = GameTranslationGetter.GetTranslaitonSetFromLanguageCode("en-us");
            var sender   = new FileBasedSend();
            var contents = sender.SendFileContents(source.getGroup().getDictionaryCopy(), list.getLangaugeByCode("en-us"), "", "");

            Debug.Log("Contents :" + contents);
        }
Ejemplo n.º 5
0
        private void saveMySourceText()
        {
            GameTranslationSet set = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(_selectedConfig.sourceLanguage.code);
            var keysToTranslate    = set.getGroup(_selectedConfig.translation_set_group).getDictionaryCopy();

            //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, saveMyDestinationLanguageText);
        }
        //NOTE: it appears as if groupid maps roughly to KEY.  But most of the time KEY is the language in those files... so I'm not sure I should take that for granted
        public NGUICSVExporter(List <TransfluentLanguage> languagesToExportTo, string groupid = "")
        {
            var allTranslationsIndexedByLanguage = new Dictionary <string, Dictionary <string, string> >();

            foreach (TransfluentLanguage lang in languagesToExportTo)
            {
                GameTranslationSet destLangDB = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(lang.code);
                if (destLangDB == null)
                {
                    Debug.LogWarning("could not find any information for language:" + lang);
                    continue;
                }
                Dictionary <string, string> translations = destLangDB.getGroup(groupid).getDictionaryCopy();
                string languageNameInNativeLanguage      = takeLanguageCodeAndTurnItIntoNativeName(lang.code);
                allTranslationsIndexedByLanguage.Add(languageNameInNativeLanguage, translations);
            }
            Init(allTranslationsIndexedByLanguage);
        }
Ejemplo n.º 7
0
        private void saveMyDestinationLanguageText()
        {
            List <WebServiceParameters> requestsToSaveLocalStrings = new List <WebServiceParameters>();

            foreach (TransfluentLanguage lang in _selectedConfig.destinationLanguages)
            {
                GameTranslationSet set = GameTranslationGetter.GetTranslaitonSetFromLanguageCode(lang.code);
                if (set == null)
                {
                    continue;
                }
                var keysToTranslate = set.getGroup(_selectedConfig.translation_set_group).getDictionaryCopy();
                //save all of our keys before requesting to transalate them, otherwise we can get errors
                var uploadAll = new SaveSetOfKeys(lang.id,
                                                  keysToTranslate,
                                                  _selectedConfig.translation_set_group,
                                                  fork: true
                                                  );
                requestsToSaveLocalStrings.Add(uploadAll);
            }
            doCalls(requestsToSaveLocalStrings, ordermytranslation);
        }
Ejemplo n.º 8
0
        //[MenuItem("Transfluent/test full loop english content")]
        public static void getTestSaveEnglishContent()
        {
            var list = ResourceLoadFacade.getLanguageList();
            GameTranslationSet source = GameTranslationGetter.GetTranslaitonSetFromLanguageCode("en-us");
            var sender   = new FileBasedSend();
            var contents = sender.SendFileContents(source.getGroup().getDictionaryCopy(), list.getLangaugeByCode("en-us"), "", "");

            Debug.Log("Contents :" + contents);

            TransfluentEditorWindowMediator mediator = new TransfluentEditorWindowMediator();

            mediator.doAuth();
            string authToken      = mediator.getCurrentAuthToken();
            string fileIdentifier = "testfile";
            var    sourceLang     = list.getLangaugeByCode("en-us");

            var saveCall     = new FileBasedSaveCall(fileIdentifier, sourceLang.id, authToken, contents);
            var caller       = new SyncronousEditorWebRequest();
            var returnStatus = caller.request(saveCall);

            Debug.Log("saved file return status:");
            Debug.Log(JsonWriter.Serialize(returnStatus));
            Debug.Log("auth token:" + authToken);
            var translateRequest = new FileTranslate("", new int[] { 3, 4 },
                                                     OrderTranslation.TranslationQuality.NATIVE_SPEAKER, fileIdentifier, sourceLang.id, authToken);
            var translateReturn = caller.request(translateRequest);

            Debug.Log("translate request file:");
            Debug.Log(JsonWriter.Serialize(translateReturn));

            var translateResultRequest = new FileBasedRead(fileIdentifier, sourceLang.id, authToken);
            var translateResultReturn  = caller.request(translateResultRequest);

            Debug.Log("translate resulting file:");
            Debug.Log(JsonWriter.Serialize(translateResultReturn));
        }
Ejemplo n.º 9
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);
        }