diff options
Diffstat (limited to 'linden/indra/llui/lltexteditor.cpp')
-rw-r--r-- | linden/indra/llui/lltexteditor.cpp | 67 |
1 files changed, 28 insertions, 39 deletions
diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index 8dcb014..369eb1e 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp | |||
@@ -398,38 +398,22 @@ LLTextEditor::LLTextEditor( | |||
398 | menu->appendSeparator("Transep"); | 398 | menu->appendSeparator("Transep"); |
399 | LLMenuGL* translatemenu = new LLMenuGL("Translate To"); | 399 | LLMenuGL* translatemenu = new LLMenuGL("Translate To"); |
400 | translatemenu->setCanTearOff(FALSE); | 400 | translatemenu->setCanTearOff(FALSE); |
401 | SpellMenuBind* t=new SpellMenuBind;t->origin=this;t->word="en"; | 401 | translatemenu->append(new LLMenuItemCallGL("en", "English", context_translate, context_enable_translate, this)); |
402 | translatemenu->append(new LLMenuItemCallGL("English", context_translate, context_enable_translate, t)); | 402 | translatemenu->append(new LLMenuItemCallGL("da", "Danish", context_translate, context_enable_translate, this)); |
403 | t=new SpellMenuBind;t->origin=this;t->word="da"; | 403 | translatemenu->append(new LLMenuItemCallGL("de", "Deutsch(German)", context_translate, context_enable_translate, this)); |
404 | translatemenu->append(new LLMenuItemCallGL("Danish", context_translate, context_enable_translate, t)); | 404 | translatemenu->append(new LLMenuItemCallGL("es", "Spanish", context_translate, context_enable_translate, this)); |
405 | t=new SpellMenuBind;t->origin=this;t->word="de"; | 405 | translatemenu->append(new LLMenuItemCallGL("fr", "French", context_translate, context_enable_translate, this)); |
406 | translatemenu->append(new LLMenuItemCallGL("Deutsch(German)", context_translate, context_enable_translate, t)); | 406 | translatemenu->append(new LLMenuItemCallGL("it", "Italian", context_translate, context_enable_translate, this)); |
407 | t=new SpellMenuBind;t->origin=this;t->word="es"; | 407 | translatemenu->append(new LLMenuItemCallGL("hu", "Hungarian", context_translate, context_enable_translate, this)); |
408 | translatemenu->append(new LLMenuItemCallGL("Spanish", context_translate, context_enable_translate, t)); | 408 | translatemenu->append(new LLMenuItemCallGL("nl", "Dutch", context_translate, context_enable_translate, this)); |
409 | t=new SpellMenuBind;t->origin=this;t->word="fr"; | 409 | translatemenu->append(new LLMenuItemCallGL("pl", "Polish", context_translate, context_enable_translate, this)); |
410 | translatemenu->append(new LLMenuItemCallGL("French", context_translate, context_enable_translate, t)); | 410 | translatemenu->append(new LLMenuItemCallGL("pt", "Portugese", context_translate, context_enable_translate, this)); |
411 | t=new SpellMenuBind;t->origin=this;t->word="it"; | 411 | translatemenu->append(new LLMenuItemCallGL("ru", "Russian", context_translate, context_enable_translate, this)); |
412 | translatemenu->append(new LLMenuItemCallGL("Italian", context_translate, context_enable_translate, t)); | 412 | translatemenu->append(new LLMenuItemCallGL("tr", "Turkish", context_translate, context_enable_translate, this)); |
413 | t=new SpellMenuBind;t->origin=this;t->word="hu"; | 413 | translatemenu->append(new LLMenuItemCallGL("uk", "Ukrainian", context_translate, context_enable_translate, this)); |
414 | translatemenu->append(new LLMenuItemCallGL("Hungarian", context_translate, context_enable_translate, t)); | 414 | translatemenu->append(new LLMenuItemCallGL("zh", "Chinese", context_translate, context_enable_translate, this)); |
415 | t=new SpellMenuBind;t->origin=this;t->word="nl"; | 415 | translatemenu->append(new LLMenuItemCallGL("ja", "Japanese", context_translate, context_enable_translate, this)); |
416 | translatemenu->append(new LLMenuItemCallGL("Dutch", context_translate, context_enable_translate, t)); | 416 | translatemenu->append(new LLMenuItemCallGL("ko", "Korean", context_translate, context_enable_translate, this)); |
417 | t=new SpellMenuBind;t->origin=this;t->word="pl"; | ||
418 | translatemenu->append(new LLMenuItemCallGL("Polish", context_translate, context_enable_translate, t)); | ||
419 | t=new SpellMenuBind;t->origin=this;t->word="pt"; | ||
420 | translatemenu->append(new LLMenuItemCallGL("Portugese", context_translate, context_enable_translate, t)); | ||
421 | t=new SpellMenuBind;t->origin=this;t->word="ru"; | ||
422 | translatemenu->append(new LLMenuItemCallGL("Russian", context_translate, context_enable_translate, t)); | ||
423 | t=new SpellMenuBind;t->origin=this;t->word="tr"; | ||
424 | translatemenu->append(new LLMenuItemCallGL("Turkish", context_translate, context_enable_translate, t)); | ||
425 | t=new SpellMenuBind;t->origin=this;t->word="uk"; | ||
426 | translatemenu->append(new LLMenuItemCallGL("Ukrainian", context_translate, context_enable_translate, t)); | ||
427 | t=new SpellMenuBind;t->origin=this;t->word="zh"; | ||
428 | translatemenu->append(new LLMenuItemCallGL("Chinese", context_translate, context_enable_translate, t)); | ||
429 | t=new SpellMenuBind;t->origin=this;t->word="ja"; | ||
430 | translatemenu->append(new LLMenuItemCallGL("Japanese", context_translate, context_enable_translate, t)); | ||
431 | t=new SpellMenuBind;t->origin=this;t->word="ko"; | ||
432 | translatemenu->append(new LLMenuItemCallGL("Korean", context_translate, context_enable_translate, t)); | ||
433 | 417 | ||
434 | menu->appendMenu(translatemenu); | 418 | menu->appendMenu(translatemenu); |
435 | menu->appendSeparator("Spelsep"); | 419 | menu->appendSeparator("Spelsep"); |
@@ -483,15 +467,20 @@ void LLTextEditor::context_copy(void* data) | |||
483 | 467 | ||
484 | BOOL LLTextEditor::context_enable_translate(void * data) | 468 | BOOL LLTextEditor::context_enable_translate(void * data) |
485 | { | 469 | { |
486 | SpellMenuBind* t = (SpellMenuBind*)data; | 470 | LLTextEditor* editor = (LLTextEditor*)data; |
487 | return (t && t->origin && t->origin->canTranslate()); | 471 | return editor && editor->canTranslate(); |
488 | } | 472 | } |
489 | 473 | ||
490 | void LLTextEditor::context_translate(void * data) | 474 | void LLTextEditor::context_translate(void * data) |
491 | { | 475 | { |
492 | SpellMenuBind* t = (SpellMenuBind*)data; | 476 | LLTextEditor* line = (LLTextEditor*)data; |
493 | LLTextEditor* line = t->origin; | 477 | LLMenuGL* menu = line ? (LLMenuGL*)(line->mPopupMenuHandle.get()) : NULL; |
494 | const std::string &toLang = t->word;//LLTranslate::getTranslateLanguage(); | 478 | LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translate To", TRUE) : NULL; |
479 | if (!translate_menu) | ||
480 | { | ||
481 | return; | ||
482 | } | ||
483 | const std::string to_lang = translate_menu->getHighlightedItem()->getName(); | ||
495 | 484 | ||
496 | bool has_text = false; | 485 | bool has_text = false; |
497 | S32 start, length; | 486 | S32 start, length; |
@@ -512,8 +501,8 @@ void LLTextEditor::context_translate(void * data) | |||
512 | if (has_text) | 501 | if (has_text) |
513 | { | 502 | { |
514 | const std::string to_translate = wstring_to_utf8str(line->getWText().substr(start, length)); | 503 | const std::string to_translate = wstring_to_utf8str(line->getWText().substr(start, length)); |
515 | LLHTTPClient::ResponderPtr result = TextChatTranslationReceiver::build(toLang, line, start, length); | 504 | LLHTTPClient::ResponderPtr result = TextChatTranslationReceiver::build(to_lang, line, start, length); |
516 | LLTranslate::translateMessage(result,"", toLang, to_translate); | 505 | LLTranslate::translateMessage(result,"", to_lang, to_translate); |
517 | } | 506 | } |
518 | } | 507 | } |
519 | 508 | ||