/// <summary> /// Downloads translations for the specified provider. /// </summary> /// <param name="type">Provider type.</param> /// <returns></returns> private bool FetchTranslations(TranslationProviderType type) { if (!apiAvailable) { return(false); } if (type == TranslationProviderType.App) { return(false); } if (type == TranslationProviderType.Operations) { return(false); } if (type == TranslationProviderType.Expeditions) { return(false); } var apiUri = new Uri(kcvApiUrl + type.ToString().ToLower() + "/"); using (var client = new ViewerWebClient()) { byte[] responseBytes; try { responseBytes = client.UploadValues(apiUri, "POST", this.DefaultRequestParameters()); Debug.WriteLine("{0}: API request sent for {1}, URL: {2}. Response: {3}.", nameof(Updater), type, apiUri, Encoding.UTF8.GetString(responseBytes)); } catch (Exception ex) { Debug.WriteLine("{0} API request sent for {1}, URL: {2}. Request failed with exception {3}.", nameof(Updater), type, apiUri, ex.Message); return(false); } return(TranslationDataProvider.LoadJson(type, responseBytes)); } }
private static string SerialisationPath(TranslationProviderType type, string culture) => Path.Combine(translationsPath, culture, type.ToString() + ".xml");