Skip to content

Commit

Permalink
Fix for #66
Browse files Browse the repository at this point in the history
  • Loading branch information
tombogle committed Jul 5, 2019
1 parent 0e516e5 commit 71d4749
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/L10NSharp/UI/LanguageChoosingDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ void Application_Idle(object sender, EventArgs e)
var translator = new BingTranslator("en", _requestedCulture.TwoLetterISOLanguageName);
try
{
var s = translator.TranslateText(string.Format(_originalMessageTemplate, _requestedCulture.EnglishName, _requestedCulture.NativeName));
var s = translator.TranslateText(string.Format(_originalMessageTemplate, _requestedCulture.EnglishName));
if (s.Contains("{1}") && s.Length > 5) // If we just get back "{1} or "({1})", we won't consider that useful.
{
// Bing will presumably have translated the English string into the native language, so now we want
// to display the English name in parentheses. (As a sanity check, we could look to see whether the
// native name is in the string, but there could be situations where it may not be an exact match.)
s = string.Format(s.Replace("{1}", "{0}"), _requestedCulture.EnglishName);
}
else
s = translator.TranslateText(string.Format(_originalMessageTemplate, _requestedCulture.EnglishName, _requestedCulture.NativeName));
if (!string.IsNullOrEmpty(s))
{
_messageLabel.Text = s;
Expand Down

0 comments on commit 71d4749

Please sign in to comment.