TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Omar Kh
NA
301
21.6k
how to translate from language to another in c# ASP.NET?
Mar 4 2021 12:13 PM
im working on a project (Names Translator ) in c# ASP.NET
this is my code
public
String Translate(String word)
{
var toLanguage =
"en"
;
//English
var fromLanguage =
"ar"
;
//Deutsch
var url = $
"https://translate.googleapis.com/translate_a/single?client=gtx&sl={fromLanguage}&tl={toLanguage}&dt=t&q={HttpUtility.UrlEncode(word)}"
;
var webClient =
new
WebClient
{
Encoding = System.Text.Encoding.UTF8
};
var result = webClient.DownloadString(url);
try
{
result = result.Substring(4, result.IndexOf(
"\""
, 4, StringComparison.Ordinal) - 4);
return
result;
}
catch
{
return
"Error"
;
}
}
and its works for most names
but sometimes "google translate" translate the names literally
for example
the result will be
He was authorized by
Mohamed Ahmed
????=he was authorized
it translate the name literally
when i go to google translate and translate the same name
it gives me the same wrong translation
but as you notice from the picture "khwlh muhamad ahmad next to red arrow" appear below is what i want !
how can i achive this ?
i need help ! thank you
Reply
Answers (
1
)
check the filename existence in the list list[] before move (rename)
How to access SQL Server via UWP .Net Core app?