|
发表于 2023-12-20 09:15:00
|
显示全部楼层
代码是这样的
- ChromeTranslateClient* chrome_translate_client = ChromeTranslateClient::FromWebContents(web_contents);
- if (!chrome_translate_client)
- break;
- std::string source_language = translate::kUnknownLanguageCode;
- std::string target_language;
- chrome_translate_client->GetTranslateLanguages(web_contents, &source_language, &target_language);
- translate::TranslateManager* translate_manager = ChromeTranslateClient::GetManagerFromWebContents(web_contents);
- if (!translate_manager)
- break;
- if (!chrome_translate_client->GetLanguageState().IsPageTranslated())
- translate_manager->TranslatePage(source_language, target_language, false);
- else
- translate_manager->RevertTranslation();
复制代码 |
|