@@ -294,13 +294,9 @@ void TranslateResxFilesAsync(string sourceResx, string sourceLng, List<string> d
294
294
if ( string . IsNullOrWhiteSpace ( orgText ) )
295
295
continue ;
296
296
297
- // Read the Key
298
- var translatorUrlKey = GetGoogleTranslatorKey_UiThread ( orgText ) ;
299
- if ( ! translatorUrlKey . Success )
300
- continue ;
301
-
297
+ // There is no longer a key to validate
302
298
// the key
303
- var textTranslatorUrlKey = translatorUrlKey . Result ;
299
+ var textTranslatorUrlKey = "" ;
304
300
305
301
string translated = string . Empty ;
306
302
bool success = false ;
@@ -433,72 +429,76 @@ private void ImportExcel(string excelFile, string resxFile, string sheetName, st
433
429
434
430
internal delegate OpResult GetGoogleTranslatorKeyDeligate ( string textToTranslate ) ;
435
431
436
- internal OpResult GetGoogleTranslatorKey ( string textToTranslate )
437
- {
438
- if ( IsGoogleTranslatorLoaded ( ) )
439
- {
440
- try
441
- {
442
- // ReSharper disable once PossibleNullReferenceException
443
- object result = webBrowser . Document . InvokeScript ( "Vj" , new object [ ] { textToTranslate } ) ;
444
- if ( result == null )
445
- {
446
- return new OpResult
447
- {
448
- Success = false ,
449
- Result = "Failed to find the translation function! Cantact the author please.\n "
450
- } ;
451
- }
452
- return new OpResult
453
- {
454
- Success = true ,
455
- Result = result . ToString ( )
456
- } ;
457
- }
458
- catch ( Exception ex )
459
- {
460
- return new OpResult
461
- {
462
- Success = false ,
463
- Result = ex . Message
464
- } ;
465
- }
466
- }
467
- else
468
- {
469
- return new OpResult
470
- {
471
- Success = false ,
472
- Result = "Google Translator is not loaded yet!"
473
- } ;
474
- }
475
- }
476
-
477
- internal OpResult GetGoogleTranslatorKey_UiThread ( string textToTranslate )
478
- {
479
- if ( this . InvokeRequired )
480
- {
481
- var asyncHandler = this . BeginInvoke ( new GetGoogleTranslatorKeyDeligate ( GetGoogleTranslatorKey ) ,
482
- new object [ ] { textToTranslate } ) ;
483
-
484
- asyncHandler . AsyncWaitHandle . WaitOne ( ) ;
485
-
486
- var result = this . EndInvoke ( asyncHandler ) as OpResult ;
487
- if ( result != null )
488
- {
489
- return result ;
490
- }
491
- return new OpResult ( )
492
- {
493
- Success = false ,
494
- Result = "Failed to get the key for the translator from main ui thread."
495
- } ;
496
- }
497
- else
498
- {
499
- return GetGoogleTranslatorKey ( textToTranslate ) ;
500
- }
501
- }
432
+ #region Old core to read old GoogleTranslation Validation Key
433
+
434
+ //internal OpResult GetGoogleTranslatorKey(string textToTranslate)
435
+ //{
436
+ // if (IsGoogleTranslatorLoaded())
437
+ // {
438
+ // try
439
+ // {
440
+ // // ReSharper disable once PossibleNullReferenceException
441
+ // object result = webBrowser.Document.InvokeScript("Vj", new object[] { textToTranslate });
442
+ // if (result == null)
443
+ // {
444
+ // return new OpResult
445
+ // {
446
+ // Success = false,
447
+ // Result = "Failed to find the translation function! Cantact the author please.\n"
448
+ // };
449
+ // }
450
+ // return new OpResult
451
+ // {
452
+ // Success = true,
453
+ // Result = result.ToString()
454
+ // };
455
+ // }
456
+ // catch (Exception ex)
457
+ // {
458
+ // return new OpResult
459
+ // {
460
+ // Success = false,
461
+ // Result = ex.Message
462
+ // };
463
+ // }
464
+ // }
465
+ // else
466
+ // {
467
+ // return new OpResult
468
+ // {
469
+ // Success = false,
470
+ // Result = "Google Translator is not loaded yet!"
471
+ // };
472
+ // }
473
+ //}
474
+
475
+ //internal OpResult GetGoogleTranslatorKey_UiThread(string textToTranslate)
476
+ //{
477
+ // if (this.InvokeRequired)
478
+ // {
479
+ // var asyncHandler = this.BeginInvoke(new GetGoogleTranslatorKeyDeligate(GetGoogleTranslatorKey),
480
+ // new object[] {textToTranslate});
481
+
482
+ // asyncHandler.AsyncWaitHandle.WaitOne();
483
+
484
+ // var result = this.EndInvoke(asyncHandler) as OpResult;
485
+ // if (result != null)
486
+ // {
487
+ // return result;
488
+ // }
489
+ // return new OpResult()
490
+ // {
491
+ // Success = false,
492
+ // Result = "Failed to get the key for the translator from main ui thread."
493
+ // };
494
+ // }
495
+ // else
496
+ // {
497
+ // return GetGoogleTranslatorKey(textToTranslate);
498
+ // }
499
+ //}
500
+
501
+ #endregion
502
502
503
503
504
504
bool IsGoogleTranslatorLoaded ( )
@@ -520,17 +520,6 @@ private void frmMain_Load(object sender, EventArgs e)
520
520
521
521
private void btnTranslate_Click ( object sender , EventArgs e )
522
522
{
523
- var a = new Action ( ( ) =>
524
- {
525
- var result = GetGoogleTranslatorKey_UiThread ( txtSrc . Text ) ;
526
- if ( result . Success )
527
- {
528
-
529
- }
530
-
531
- } ) ;
532
- a . BeginInvoke ( ( v ) => { } , null ) ;
533
- return ;
534
523
535
524
if ( cmbDesc . SelectedIndex == - 1 || cmbSrc . SelectedIndex == - 1 )
536
525
{
@@ -547,13 +536,8 @@ private void btnTranslate_Click(object sender, EventArgs e)
547
536
var lngDest = ( ( KeyValuePair < string , string > ) cmbDesc . SelectedItem ) . Key ;
548
537
var text = txtSrc . Text ;
549
538
550
- var textTranslatorResult = GetGoogleTranslatorKey ( text ) ;
551
- if ( ! textTranslatorResult . Success )
552
- {
553
- txtDesc . Text = textTranslatorResult . Result ;
554
- return ;
555
- }
556
- var textTranslatorUrlKey = textTranslatorResult . Result ;
539
+ // There is no longer a key to validate
540
+ var textTranslatorUrlKey = "" ;
557
541
558
542
IsBusy ( true ) ;
559
543
GTranslateService . TranslateAsync (
0 commit comments