当前位置: 首页>>代码示例>>C#>>正文


C# UploadedFile.ExportTranslation方法代码示例

本文整理汇总了C#中UploadedFile.ExportTranslation方法的典型用法代码示例。如果您正苦于以下问题:C# UploadedFile.ExportTranslation方法的具体用法?C# UploadedFile.ExportTranslation怎么用?C# UploadedFile.ExportTranslation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UploadedFile的用法示例。


在下文中一共展示了UploadedFile.ExportTranslation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExportFileToDirectory

    private static void ExportFileToDirectory(UploadedFile file, DirectoryInfo destination, IEnumerable<CultureInfo> cultures)
    {
        foreach (var culture in cultures)
        {
            var cultureDirectory = new DirectoryInfo(Path.Combine(destination.FullName, OneSky.LocaleCodeHelper.ConvertToLocaleCode(culture.Name)));
            if (!cultureDirectory.Exists)
            {
                cultureDirectory.Create();
            }

            using (var memoryStream = new MemoryStream())
            {
                var exportFile = new FileInfo(Path.Combine(cultureDirectory.FullName, file.Filename));

                var exportTranslationState = file.ExportTranslation(culture, memoryStream).Result;
                if (exportTranslationState == UploadedFile.ExportTranslationState.Success)
                {
                    memoryStream.Position = 0;
                    using (Stream fileStream = File.OpenWrite(exportFile.FullName))
                    {
                        memoryStream.CopyTo(fileStream);
                        Console.WriteLine("[SUCCESS] Exporting: " + exportFile.FullName + " Locale: " + OneSky.LocaleCodeHelper.ConvertToLocaleCode(culture.Name));
                    }
                }
                else if (exportTranslationState == UploadedFile.ExportTranslationState.NoContent)
                {
                    Console.WriteLine("[WARNING] Exporting: " + exportFile.FullName + " Locale: " + OneSky.LocaleCodeHelper.ConvertToLocaleCode(culture.Name) + " has no translations!");
                }
                else
                {
                    Console.WriteLine("[FAILED] Exporting: " + exportFile.FullName + " Locale: " + OneSky.LocaleCodeHelper.ConvertToLocaleCode(culture.Name));
                }
            }
        }
    }
开发者ID:Art1stical,项目名称:AHRUnrealEngine,代码行数:35,代码来源:Localisation.Automation.cs

示例2: ExportFileToDirectory

    private void ExportFileToDirectory(UploadedFile file, DirectoryInfo destination, IEnumerable<string> cultures)
    {
        foreach (var culture in cultures)
        {
            var cultureDirectory = new DirectoryInfo(Path.Combine(destination.FullName, culture));
            if (!cultureDirectory.Exists)
            {
                cultureDirectory.Create();
            }

            using (var memoryStream = new MemoryStream())
            {
                var exportFile = new FileInfo(Path.Combine(cultureDirectory.FullName, file.Filename));

                var exportTranslationState = file.ExportTranslation(culture, memoryStream).Result;
                if (exportTranslationState == UploadedFile.ExportTranslationState.Success)
                {
                    memoryStream.Position = 0;
                    using (Stream fileStream = File.OpenWrite(exportFile.FullName))
                    {
                        memoryStream.CopyTo(fileStream);
                        Console.WriteLine("[SUCCESS] Exporting: " + exportFile.FullName + " Locale: " + culture);
                    }
                    FileInfo exportFileCopy = new FileInfo(Path.Combine(exportFile.DirectoryName, Path.GetFileNameWithoutExtension(exportFile.Name) + "_FromOneSky" + exportFile.Extension));
                    // Add/check out backed up POs from OneSky.
                    if (P4Enabled)
                    {
                        UE4Build.AddBuildProductsToChangelist(OneSkyDownloadedPOChangeList, new List<string>() {exportFileCopy.FullName} );
                    }
                    File.Copy(exportFile.FullName, exportFileCopy.FullName, true);
                }
                else if (exportTranslationState == UploadedFile.ExportTranslationState.NoContent)
                {
                    Console.WriteLine("[WARNING] Exporting: " + exportFile.FullName + " Locale: " + culture + " has no translations!");
                }
                else
                {
                    Console.WriteLine("[FAILED] Exporting: " + exportFile.FullName + " Locale: " + culture);
                }
            }
        }
    }
开发者ID:mymei,项目名称:UE4,代码行数:42,代码来源:Localisation.Automation.cs

示例3: ExportOneSkyTranslationWithRetry

	private UploadedFile.ExportTranslationState ExportOneSkyTranslationWithRetry(UploadedFile OneSkyFile, string Culture, MemoryStream MemoryStream)
	{
		const int MAX_COUNT = 3;

		long StartingMemPos = MemoryStream.Position;
		int Count = 0;
		for (;;)
		{
			try
			{
				return OneSkyFile.ExportTranslation(Culture, MemoryStream).Result;
			}
			catch (Exception)
			{
				if (++Count < MAX_COUNT)
				{
					MemoryStream.Position = StartingMemPos;
					Console.WriteLine("ExportOneSkyTranslation attempt {0}/{1} failed. Retrying...", Count, MAX_COUNT);
					continue;
				}

				Console.WriteLine("ExportOneSkyTranslation attempt {0}/{1} failed.", Count, MAX_COUNT);
				break;
			}
		}

		return UploadedFile.ExportTranslationState.Failure;
	}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:28,代码来源:OneSkyLocalizationProvider.cs

示例4: ExportFileToDirectory

	private static void ExportFileToDirectory(UploadedFile file, DirectoryInfo destination, IEnumerable<string> cultures)
	{
		foreach (var culture in cultures)
		{
			string finalCulture = culture;
			if (culture == "es")
			{
				// we no longer export es, instead replacing it with es-ES
				continue;
			}
			else if (culture == "es-ES")
			{
				finalCulture = "es";
			}

			var cultureDirectory = new DirectoryInfo(Path.Combine(destination.FullName, finalCulture));
			if (!cultureDirectory.Exists)
			{
				cultureDirectory.Create();
			}

			using (var memoryStream = new MemoryStream())
			{
				var exportFile = new FileInfo(Path.Combine(cultureDirectory.FullName, file.Filename));

				var exportTranslationState = file.ExportTranslation(culture, memoryStream).Result;
				if (exportTranslationState == UploadedFile.ExportTranslationState.Success)
				{
					memoryStream.Position = 0;
					using (Stream fileStream = File.Open(exportFile.FullName, FileMode.Create))
					{
						memoryStream.CopyTo(fileStream);
						Console.WriteLine("[SUCCESS] Exporting: " + exportFile.FullName + " Source Locale: " + culture + " Target Locale: " + finalCulture);
					}
				}
				else if (exportTranslationState == UploadedFile.ExportTranslationState.NoContent)
				{
						Console.WriteLine("[WARNING] Exporting: " + exportFile.FullName + " Source Locale: " + culture + " Target Locale: " + finalCulture + " has no translations!");
				}
				else
				{
						Console.WriteLine("[FAILED] Exporting: " + exportFile.FullName + " Source Locale: " + culture + " Target Locale: " + finalCulture);
				}
			}
		}
	}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:46,代码来源:LauncherLocalization.Automation.cs


注:本文中的UploadedFile.ExportTranslation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。