Пример #1
0
        // Works.
        // Gets TranslationFile. Converts it to 'Language' file format. Saves it in Assets project
        // folder in the same relative path as was on the server.
        private static void SaveTranslationFileToProjectLanguageFile(TranslationFile translationFile, TranslateProject projectSettings)
        {
            var tempPath = Path.GetTempFileName();

            File.WriteAllText(tempPath, translationFile.content);

            var db = GetMultiLangStringDB(translationFile.pathOnServer);

            POUtility.ImportFile(db, tempPath, (SystemLanguage)projectSettings.sourceLanguageID, true); // TODO: 1. Update reference language from settings. 2. Q.: When last param true and when false?
            File.Delete(tempPath);

            SaveLangDBFileAtPath(db, translationFile.pathOnServer);
        }
Пример #2
0
        // Works. Takes file name as it is on server. Downloads it. Returns as TranslationFile.
        private static TranslationFile DownloadTranslationFile(string filePathOnServer, SystemLanguage translationLanguage, TranslateProject projectSettings)
        {
            var translationFile = new TranslationFile();

            translationFile.pathOnServer = filePathOnServer;
            filePathOnServer             = WWW.EscapeURL(filePathOnServer);

            Downloader.Response response;
            Downloader.SendGetData(serverUrl
                                   + "/v1/files/translation-file?projectID=" + projectSettings.id
                                   + "&languageID=" + serverLanguageCodes[translationLanguage.ToString()]
                                   + "&branch=" + projectSettings.currentBranch
                                   + "&file=" + filePathOnServer,
                                   out response);
            translationFile.content = response.body;

            return(translationFile);
        }