//[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); }
//[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)); }
//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); }