|
If we translate long text, returned json has a few row with translated text
example: written number from 1 to 40
one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty one twenty two twenty three twenty four twenty five twenty six twenty seven twenty eight twenty nine thirty thirty one thirty two thirty three thirty four thirty five thirty six thirty seven thirty eight thirty nine forty
on result we have json with two translated rows (en to ua): [[
[[
["один два три четыре пять шесть семь восемь девять десять одиннадцать двенадцать 1314 1516 1718 1920 двадцать-одна двадцать два двадцать три двадцать четыре двадцать пять двадцать шесть двадцать семь двадцать восемь двадцать девять тридцать тридцать один тридцать два тридцать три тридцать четыре тридцать пять тридцать ","one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty one twenty two twenty three twenty four twenty five twenty six twenty seven twenty eight twenty nine thirty thirty one thirty two thirty three thirty four thirty five thirty",null,null,0],
["шесть тридцать семь тридцать восемь тридцать девять сорок","six thirty seven thirty eight thirty nine forty",null,null,0]
],null,"de"]
But in code we take only first translated row from json
example
|
|
|
|
|
Thanks - will look into it.
/ravi
|
|
|
|
|
For me worked those two lines update with "null" :
if (translatedPhrase.StartsWith(",null,")) {
int index = text.IndexOf (string.Format(",null,\"{0}\"", Translator.LanguageEnumToIdentifier (sourceLanguage)));
The code was always treating translation as one word translation.
|
|
|
|
|
For me, it doesn't work, I still have lots of
" ,null,null,3," and
"\r\n"
|
|
|
|
|
Hi, i would like to know either this service (translate.googleapis.com) is free one or is there any limitation to use it? can you please confirm at earliest to use this model of this project. this project really useful for our requirement and perfect match.
Thanks,
Vasanth.
|
|
|
|
|
Hi Vasanth,
Google Translator is simply an academic demonstration of how to programmatically use Google's translation service. For professional use, please see the pricing information at this[^] Google page.
/ravi
|
|
|
|
|
Hey. It is great app, but is it possible to add option of downloading noty only translated word, but also a definition of it (from google translate)? Thanks
|
|
|
|
|
Hi Rafal,
Downloading a word's definition is outside the scope of Google Translator.
That being said, you can easily write a class that retrieves a word's definition, by using a framework I specifically created to perform tasks of this nature. See these 2 articles:
/ravi
|
|
|
|
|
All thanks Mr. Ravi you don't know how much you helped me
|
|
|
|
|
Glad you found the article helpful!
/ravi
|
|
|
|
|
Any way you could add an optional API access key along with a gnm model? Here is what is needed:
Class: Google::Cloud::Translate::Api — Documentation for google-cloud-translate (0.22.1)[^]
Using the neural machine translation model:
require "google/cloud/translate"
translate = Google::Cloud::Translate.new
translation = translate.translate "Hello world!",
to: "la", model: "nmt"
translation.to_s #=> "Salve mundi!"
translation.model #=> "nmt"
Please let me know!
Thank you,
Ilia
|
|
|
|
|
Hi Ilia, I'm afraid that's outside the scope of the article, which describes sans API-key access to the Google Translate API.
/ravi
|
|
|
|
|
Website ends up in 404.
Thus string url = string.Format ("https://translate.googleapis.com/translate_a/single?client=gtx&sl={0}&tl={1}&dt=t&q={2}", needs to be fixed.
Regards,
jung-kreidler
|
|
|
|
|
Thank you. I'll look into it.
/ravi
|
|
|
|
|
Can you provide helper class that can detect language of user input in c#?
I am able to do that using Microsoft translator api with authorization.But,I want to do it without authorization.
|
|
|
|
|
Sorry, I don't know how to do this.
/ravi
|
|
|
|
|
Hello,
When is included some symbols in the messaje, the translation fails, or do extrange things. And the problema is, these symbols are very used, specially in books or narrative text.
The symbols that I've detected, are the quotes symbol (") and the apostrofe (')
Can you fix it?
Currently, for Works with it, I have to pre prepare the string before send through your class to the translator. It Works... fine, but not perfect.
Thanks for all.
|
|
|
|
|
Sandl Okino wrote: Currently, for Works with it, I have to pre prepare the string before Thanks for the bug report, Sandl. By "prepare", do you mean HTML encode the quotes and special symbols?
/ravi
|
|
|
|
|
Hmmm nop,, for prepare, I mean change the conflicting simbols for a random text that google will can't translate, and keep it, and after receipt the translation, I can undo the change.
Before use this system, I tried to use the URLEncode and the HTMlEncode of system.net class (If I'm not wrong) but they don't work.
Well. if you can fix this anoying problema, I thankyou very very much. I use this lib for an automatic tool that translate the selected text on the clipboard, and well. With this bug simple lines of a book can't be translated correctly.
An example:
- Hello man! I'm your friend! - Say the Little man to the giant.
- "who is this guy? I don't know it!" - think the giant, while smiles to the Little man.
Well... the example is stupid, but google will be have problems whith the dashes, quotes and other similar simbols like / \ |. It think that these simbols are separating two diferent sentenses or part of the json,and manipulate wrongly the translation.
Well, that is all, and sorry for the late of my answer. ¡thanks for all!
|
|
|
|
|
I remember in my code i had to make several changes in the text before and after translation here is the code it may need some adaptations:
private static Dictionary<string, string=""> ReplacementsA = null;
private static Dictionary<string, string=""> ReplacementsB = null;
private static Dictionary<string, string=""> ReplacementsC = null;
// Initialize replacement arrays
private static void Init_Replacements()
{
ReplacementsA = new Dictionary<string, string="">
{
{"%", "<p0c>"},
{"&", "<c0e>"},
{";", "<p0v>"},
{"[", "<sb0l>"},
{"]", "<sb0r>"}
};
ReplacementsB = new Dictionary<string, string="">
{
{" @", "@"},
{"@ ", "@"},
{"'", "'"},
{"'", "'"},
{""", "\""},
{"& lt ;", "<"},
{"<", "<"},
{">", ">"},
{"& gt ;", ">"},
{"\u00ae", "®"},
{"%0d", "\n"},
{"%0D", "\n"},
{"%0a", "\n"},
{"☺", "\n"}, // mymemory end of line replacement
{"\\u003c", "<"},
{"\\u003e", ">"}
};
ReplacementsC = new Dictionary<string, string="">
{
{"<p0c>", "%"},
{"<p0c>", "%"},
{"<c0e>", "&"},
{"<c0e>", "&"},
{"<p0v>", ";"},
{"<p0v>", ";"},
{"<p0v>", ";"},
{"<> P0V", ";"},
{"<פּ0וו>", ";"},
{"",""},
{"",""},
{"<sb0l>","["},
{"<sb0l>","["},
{"<sb0l>","["},
{"<sb0r>","]"},
{"<sb0r>","]"},
{"<sb0r>","]"},
{" ;",";"},
{"//","/"}
};
}
public static string replace_chars_before(string storeplace)
{
return StringBuilderReplace(new StringBuilder(storeplace), ReplacementsA);
}
public static string replace_chars_after(string storeplace)
{
while (storeplace.IndexOf(" ;") != -1) storeplace = storeplace.Replace(" ;", ";");
storeplace = StringBuilderReplace(new StringBuilder(storeplace), ReplacementsB);
while (storeplace.IndexOf(" >") != -1) storeplace = storeplace.Replace(" >", ">");
while (storeplace.IndexOf("< ") != -1) storeplace = storeplace.Replace("< ", "<");
return StringBuilderReplace(new StringBuilder(storeplace), ReplacementsC);
}
|
|
|
|
|
O, thanks! thanks soo mutch! I have to try it! thanks :P
|
|
|
|
|
can it detect the language of the original speech?
|
|
|
|
|
|
|
|