Skip to content

Commit

Permalink
v1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
niksedk committed Jan 15, 2021
1 parent ff3c114 commit 491dbdc
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 19 deletions.
Binary file added src/.vs/XmlContentTranslator/v16/.suo
Binary file not shown.
11 changes: 6 additions & 5 deletions src/XmlContentTranslator/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions src/XmlContentTranslator/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,11 @@ public static string TranslateTextViaScreenScraping(string input, string languag
input = input.Replace("'", "'");

//string url = String.Format("https://www.google.com/translate_t?hl=en&ie=UTF8&text={0}&langpair={1}", HttpUtility.UrlEncode(input), languagePair);
string url = String.Format("https://translate.google.com/?hl=en&eotf=1&sl={0}&tl={1}&q={2}", languagePair.Substring(0, 2), languagePair.Substring(3), HttpUtility.UrlEncode(input));
var url = $"https://translate.google.com/?hl=en&eotf=1&sl={languagePair.Substring(0, 2)}&tl={languagePair.Substring(3)}&q={HttpUtility.UrlEncode(input)}";

var webClient = new WebClient { Encoding = Encoding.Default };
string result = webClient.DownloadString(url);
int startIndex = result.IndexOf("<span id=result_box", StringComparison.Ordinal);
var result = webClient.DownloadString(url);
var startIndex = result.IndexOf("<span id=result_box", StringComparison.Ordinal);
var sb = new StringBuilder();
if (startIndex > 0)
{
Expand All @@ -577,7 +577,7 @@ public static string TranslateTextViaScreenScraping(string input, string languag
}
}
}
string res = sb.ToString();
var res = sb.ToString();
res = res.Replace("<BR/>", Environment.NewLine);
res = res.Replace("<BR />", Environment.NewLine);
res = res.Replace("< BR />", Environment.NewLine);
Expand Down Expand Up @@ -615,6 +615,7 @@ private void GoogleTranslateSelectedLines()
foreach (ListViewItem item in listViewLanguageTags.SelectedItems)
{
oldText = item.SubItems[1].Text;
oldText = string.Join(Environment.NewLine, oldText.SplitToLines());
oldLines.Add(oldText);
var urlEncode = HttpUtility.UrlEncode(sb + newText);
if (urlEncode.Length >= 1000)
Expand Down Expand Up @@ -1016,5 +1017,9 @@ private void listViewLanguageTags_DoubleClick(object sender, EventArgs e)
}
}

private void Main_Resize(object sender, EventArgs e)
{
listViewLanguageTags.Columns[listViewLanguageTags.Columns.Count - 1].Width = -2;
}
}
}
4 changes: 2 additions & 2 deletions src/XmlContentTranslator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
[assembly: AssemblyVersion("1.9.0.0")]
[assembly: AssemblyFileVersion("1.9.0.0")]
4 changes: 2 additions & 2 deletions src/XmlContentTranslator/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/XmlContentTranslator/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/XmlContentTranslator/Translator/Formatting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public string SetTagsAndReturnTrimmed(string text, string source)
char.IsLetterOrDigit(lines[0][lines[0].Length - 1]) &&
char.IsLower(lines[1][0]))
{
text = text.Replace(Environment.NewLine, " ").Replace(" ", " ");
text = string.Join(" ", text.SplitToLines()).Replace(" ", " ");
AutoBreak = true;
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/XmlContentTranslator/XmlContentTranslator.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand All @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>XmlContentTranslator</RootNamespace>
<AssemblyName>XmlContentTranslator</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ApplicationIcon>Web_XML.ico</ApplicationIcon>
<FileUpgradeFlags>
Expand All @@ -28,6 +28,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -36,6 +37,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion src/XmlContentTranslator/app.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/></startup></configuration>

0 comments on commit 491dbdc

Please sign in to comment.