How to use translate method in Airtest

Best Python code snippet using Airtest

translate.py

Source:translate.py Github

copy

Full Screen

1#!/usr/bin/env python2# Copyright (c) 2011 The Chromium Authors. All rights reserved.3# Use of this source code is governed by a BSD-style license that can be4# found in the LICENSE file.5import glob6import logging7import os8import shutil9import tempfile10import pyauto_functional # Must be imported before pyauto11import pyauto12class TranslateTest(pyauto.PyUITest):13 """Tests that translate works correctly"""14 spanish = 'es'15 after_translate = 'AFTER_TRANSLATE'16 before_translate = 'BEFORE_TRANSLATE'17 translating = 'TRANSLATING'18 translation_error = 'TRANSLATION_ERROR'19 def Debug(self):20 """ Test method for experimentation. """21 while True:22 raw_input('Hit <enter> to dump translate info.. ')23 self.pprint(self.GetTranslateInfo())24 def _GetDefaultSpanishURL(self):25 return self.GetHttpURLForDataPath('translate', self.spanish, 'google.html')26 def _GetDefaultEnglishURL(self):27 return self.GetHttpURLForDataPath('title1.html')28 def _NavigateAndWaitForBar(self, url, window_index=0, tab_index=0):29 self.NavigateToURL(url, window_index, tab_index)30 self.assertTrue(self.WaitForInfobarCount(31 1, windex=window_index, tab_index=tab_index))32 def _ClickTranslateUntilSuccess(self, window_index=0, tab_index=0):33 """Since the translate can fail due to server error, continue trying until34 it is successful or until it has tried too many times."""35 max_tries = 1036 curr_try = 037 while (curr_try < max_tries and38 not self.ClickTranslateBarTranslate(window_index=window_index,39 tab_index=tab_index)):40 curr_try = curr_try + 141 if curr_try == max_tries:42 self.fail('Translation failed more than %d times.' % max_tries)43 def _AssertTranslateWorks(self, url, original_language):44 """Translate the page at the given URL and assert that the page has been45 translated.46 """47 self._NavigateAndWaitForBar(url)48 translate_info = self.GetTranslateInfo()49 self.assertEqual(original_language, translate_info['original_language'])50 self.assertFalse(translate_info['page_translated'])51 self.assertTrue(translate_info['can_translate_page'])52 self.assertTrue('translate_bar' in translate_info)53 self._ClickTranslateUntilSuccess()54 translate_info = self.GetTranslateInfo()55 self.assertTrue(translate_info['can_translate_page'])56 self.assertTrue('translate_bar' in translate_info)57 translate_bar = translate_info['translate_bar']58 self.assertEquals(self.after_translate,59 translate_info['translate_bar']['bar_state'])60 self.assertEquals(original_language,61 translate_bar['original_lang_code'])62 def testTranslate(self):63 """Tests that a page was translated if the user chooses to translate."""64 self._AssertTranslateWorks(self._GetDefaultSpanishURL(), self.spanish)65 def testNoTranslate(self):66 """Tests that a page isn't translated if the user declines translate."""67 self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())68 self.SelectTranslateOption('decline_translation')69 translate_info = self.GetTranslateInfo()70 self.assertEqual(self.spanish, translate_info['original_language'])71 self.assertFalse(translate_info['page_translated'])72 self.assertTrue(translate_info['can_translate_page'])73 # If the user goes to the site again, the infobar should drop down but74 # the page should not be automatically translated.75 self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())76 translate_info = self.GetTranslateInfo()77 self.assertFalse(translate_info['page_translated'])78 self.assertTrue(translate_info['can_translate_page'])79 self.assertTrue('translate_bar' in translate_info)80 self.assertEquals(self.before_translate,81 translate_info['translate_bar']['bar_state'])82 def testNeverTranslateLanguage(self):83 """Tests that blacklisting a language for translate works."""84 self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())85 self.SelectTranslateOption('never_translate_language')86 translate_info = self.GetTranslateInfo()87 self.assertEqual(self.spanish, translate_info['original_language'])88 self.assertFalse(translate_info['page_translated'])89 self.assertFalse(translate_info['can_translate_page'])90 spanish_wikipedia = 'http://es.wikipedia.org/wiki/Wikipedia:Portada'91 self.NavigateToURL(spanish_wikipedia)92 translate_info = self.GetTranslateInfo()93 self.assertEqual(self.spanish, translate_info['original_language'])94 self.assertFalse(translate_info['page_translated'])95 self.assertFalse(translate_info['can_translate_page'])96 def testAlwaysTranslateLanguage(self):97 """Tests that the always translate a language option works."""98 self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())99 self.SelectTranslateOption('toggle_always_translate')100 self._ClickTranslateUntilSuccess()101 translate_info = self.GetTranslateInfo()102 self.assertEquals(self.spanish, translate_info['original_language'])103 self.assertTrue(translate_info['page_translated'])104 self.assertTrue(translate_info['can_translate_page'])105 self.assertTrue('translate_bar' in translate_info)106 self.assertEquals(self.after_translate,107 translate_info['translate_bar']['bar_state'])108 # Go to another spanish site and verify that it is translated.109 # Note that the 'This page has been translated..." bar will show up.110 self._NavigateAndWaitForBar(111 'http://es.wikipedia.org/wiki/Wikipedia:Portada')112 translate_info = self.GetTranslateInfo()113 self.assertTrue('translate_bar' in translate_info)114 curr_bar_state = translate_info['translate_bar']['bar_state']115 # We don't care whether the translation has finished, just that it is116 # trying to translate.117 self.assertTrue(curr_bar_state is self.after_translate or118 self.translating or self.translation_error,119 'Bar state was %s.' % curr_bar_state)120 def testNeverTranslateSite(self):121 """Tests that blacklisting a site for translate works."""122 spanish_google = 'http://www.google.com/webhp?hl=es'123 self._NavigateAndWaitForBar(spanish_google)124 self.SelectTranslateOption('never_translate_site')125 translate_info = self.GetTranslateInfo()126 self.assertFalse(translate_info['page_translated'])127 self.assertFalse(translate_info['can_translate_page'])128 french_google = 'http://www.google.com/webhp?hl=fr'129 # Go to another page in the same site and verify that the page can't be130 # translated even though it's in a different language.131 self.NavigateToURL(french_google)132 translate_info = self.GetTranslateInfo()133 self.assertFalse(translate_info['page_translated'])134 self.assertFalse(translate_info['can_translate_page'])135 def testRevert(self):136 """Tests that reverting a site to its original language works."""137 self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())138 self._ClickTranslateUntilSuccess()139 self.RevertPageTranslation()140 translate_info = self.GetTranslateInfo()141 self.assertFalse(translate_info['page_translated'])142 self.assertTrue(translate_info['can_translate_page'])143 def testBarNotVisibleOnSSLErrorPage(self):144 """Test Translate bar is not visible on SSL error pages."""145 self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())146 translate_info = self.GetTranslateInfo()147 self.assertTrue('translate_bar' in translate_info)148 self.assertTrue(translate_info['can_translate_page'])149 # This page is an ssl error page.150 self.NavigateToURL('https://www.sourceforge.net')151 self.assertTrue(self.WaitForInfobarCount(0))152 translate_info = self.GetTranslateInfo()153 self.assertFalse('translate_bar' in translate_info)154 def testBarNotVisibleOnEnglishPage(self):155 """Test Translate bar is not visible on English pages."""156 self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())157 translate_info = self.GetTranslateInfo()158 self.assertTrue('translate_bar' in translate_info)159 self.assertTrue(translate_info['can_translate_page'])160 # With the translate bar visible in same tab open an English page.161 self.NavigateToURL(self._GetDefaultEnglishURL())162 self.assertTrue(self.WaitForInfobarCount(0))163 translate_info = self.GetTranslateInfo()164 self.assertFalse('translate_bar' in translate_info)165 def testTranslateDiffURLs(self):166 """Test that HTTP, HTTPS, and file urls all get translated."""167 http_url = 'http://www.google.com/webhp?hl=es'168 https_url = 'https://www.google.com/webhp?hl=es'169 file_url = self._GetDefaultSpanishURL()170 for url in (http_url, https_url, file_url):171 self._AssertTranslateWorks(url, self.spanish)172 def testNotranslateMetaTag(self):173 """Test "notranslate" meta tag."""174 self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())175 self.NavigateToURL(self.GetFileURLForDataPath(176 'translate', 'notranslate_meta_tag.html'))177 self.assertTrue(self.WaitForInfobarCount(0))178 translate_info = self.GetTranslateInfo()179 self.assertFalse('translate_bar' in translate_info)180 def testToggleTranslateOption(self):181 """Test to toggle the 'Always Translate' option."""182 self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())183 # Assert the default.184 translate_info = self.GetTranslateInfo()185 self.assertFalse(translate_info['page_translated'])186 self.assertTrue('translate_bar' in translate_info)187 # Select 'Always Translate'.188 self.SelectTranslateOption('toggle_always_translate')189 self._ClickTranslateUntilSuccess()190 translate_info = self.GetTranslateInfo()191 self.assertTrue(translate_info['page_translated'])192 # Reload the tab and confirm the page was translated.193 self.GetBrowserWindow(0).GetTab(0).Reload()194 self.assertTrue(self.WaitForInfobarCount(1))195 success = self.WaitUntilTranslateComplete()196 # Sometimes the translation fails. Continue clicking until it succeeds.197 if not success:198 self._ClickTranslateUntilSuccess()199 # Uncheck 'Always Translate'200 self.SelectTranslateOption('toggle_always_translate')201 self.PerformActionOnInfobar('dismiss', 0)202 translate_info = self.GetTranslateInfo()203 self.assertTrue(translate_info['page_translated'])204 self.assertFalse('translate_bar' in translate_info)205 # Reload the tab and confirm that the page has not been translated.206 self.GetBrowserWindow(0).GetTab(0).Reload()207 translate_info = self.GetTranslateInfo()208 self.assertFalse(translate_info['page_translated'])209 self.assertTrue('translate_bar' in translate_info)210 def testSessionRestore(self):211 """Test that session restore restores the translate infobar and other212 translate settings.213 """214 # Due to crbug.com/51439, we must open two tabs here.215 self.NavigateToURL("http://www.news.google.com")216 self.AppendTab(pyauto.GURL("http://www.google.com/webhp?hl=es"))217 self.assertTrue(self.WaitForInfobarCount(1, tab_index=1))218 translate_info = self.GetTranslateInfo(tab_index=1)219 self.assertTrue('translate_bar' in translate_info)220 self.SelectTranslateOption('toggle_always_translate', tab_index=1)221 self._ClickTranslateUntilSuccess(tab_index=1)222 self.SetPrefs(pyauto.kRestoreOnStartup, 1)223 self.RestartBrowser(clear_profile=False)224 self.assertTrue(self.WaitForInfobarCount(1, tab_index=1))225 self.WaitUntilTranslateComplete(tab_index=1)226 translate_info = self.GetTranslateInfo(tab_index=1)227 self.assertTrue('translate_bar' in translate_info)228 # Sometimes translation fails. We don't really care whether it succeededs,229 # just that a translation was attempted.230 self.assertNotEqual(self.before_translate,231 translate_info['translate_bar']['bar_state'])232 def testGoBackAndForwardToTranslatePage(self):233 """Tests that translate bar re-appears after backward and forward234 navigation to a page that can be translated.235 """236 no_trans_url = self._GetDefaultEnglishURL()237 trans_url = self._GetDefaultSpanishURL()238 self._NavigateAndWaitForBar(trans_url)239 translate_info = self.GetTranslateInfo()240 self.assertTrue('translate_bar' in translate_info)241 self.NavigateToURL(no_trans_url)242 self.assertTrue(self.WaitForInfobarCount(0))243 self.assertFalse('translate_bar' in self.GetTranslateInfo())244 # Go back to the page that should be translated and assert that the245 # translate bar re-appears.246 self.GetBrowserWindow(0).GetTab(0).GoBack()247 self.assertTrue(self.WaitForInfobarCount(1))248 self.assertTrue('translate_bar' in self.GetTranslateInfo())249 # Now test going forward.250 self.NavigateToURL(no_trans_url)251 translate_info = self.GetTranslateInfo()252 self.assertFalse('translate_bar' in translate_info)253 self._AssertTranslateWorks(trans_url, self.spanish)254 self.GetBrowserWindow(0).GetTab(0).GoBack()255 self.assertTrue(self.WaitForInfobarCount(0))256 translate_info = self.GetTranslateInfo()257 self.assertFalse('translate_bar' in translate_info)258 self.GetBrowserWindow(0).GetTab(0).GoForward()259 self.assertTrue(self.WaitForInfobarCount(1))260 translate_info = self.GetTranslateInfo()261 self.assertTrue(translate_info['can_translate_page'])262 self.assertTrue('translate_bar' in translate_info)263 def testForCrashedTab(self):264 """Tests that translate bar is dimissed if the renderer crashes."""265 crash_url = 'about:crash'266 self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())267 translate_info = self.GetTranslateInfo()268 self.assertTrue('translate_bar' in translate_info)269 self.NavigateToURL(crash_url)270 self.assertTrue(self.WaitForInfobarCount(0))271 self.assertFalse('translate_bar' in self.GetTranslateInfo())272 def testTranslatePrefs(self):273 """Test the Prefs:Translate option."""274 # Assert defaults first.275 self.assertTrue(self.GetPrefsInfo().Prefs(pyauto.kEnableTranslate))276 # Uncheck.277 self.SetPrefs(pyauto.kEnableTranslate, False)278 self.NavigateToURL(self._GetDefaultSpanishURL())279 self.assertFalse('translate_bar' in self.GetTranslateInfo())280 # Restart the browser and assert the translate preference stays.281 self.RestartBrowser(clear_profile=False)282 self.assertFalse(self.GetPrefsInfo().Prefs(pyauto.kEnableTranslate))283 self.NavigateToURL(self._GetDefaultSpanishURL())284 self.assertFalse('translate_bar' in self.GetTranslateInfo())285 def testAlwaysTranslateLanguageButton(self):286 """Test the always translate language button."""287 spanish_url = self._GetDefaultSpanishURL()288 self._NavigateAndWaitForBar(spanish_url)289 # The 'Always Translate' button doesn't show up until the user has clicked290 # 'Translate' for a language 3 times.291 for unused in range(3):292 self._ClickTranslateUntilSuccess()293 self.GetBrowserWindow(0).GetTab(0).Reload()294 # Click the 'Always Translate' button.295 self.assertTrue(self.GetTranslateInfo()\296 ['translate_bar']['always_translate_lang_button_showing'])297 self.SelectTranslateOption('click_always_translate_lang_button')298 # Navigate to another Spanish page and verify it was translated.299 self._NavigateAndWaitForBar('http://www.google.com/webhp?hl=es')300 self.WaitUntilTranslateComplete()301 # Assert that a translation was attempted. We don't care if it was error302 # or success.303 self.assertNotEqual(self.before_translate,304 self.GetTranslateInfo()['translate_bar']['bar_state'])305 def testNeverTranslateLanguageButton(self):306 """Test the never translate language button."""307 spanish_url = self._GetDefaultSpanishURL()308 self._NavigateAndWaitForBar(spanish_url)309 # The 'Never Translate' button doesn't show up until the user has clicked310 # 'Nope' for a language 3 times.311 for unused in range(3):312 self.SelectTranslateOption('decline_translation')313 self.GetBrowserWindow(0).GetTab(0).Reload()314 # Click the 'Never Translate' button.315 self.assertTrue(self.GetTranslateInfo()\316 ['translate_bar']['never_translate_lang_button_showing'])317 self.SelectTranslateOption('click_never_translate_lang_button')318 # Navigate to another Spanish page and verify the page can't be translated.319 # First navigate to a French page, wait for bar, navigate to Spanish page320 # and wait for bar to go away.321 self._NavigateAndWaitForBar('http://www.google.com/webhp?hl=fr')322 self.NavigateToURL('http://www.google.com/webhp?hl=es')323 self.assertTrue(self.WaitForInfobarCount(0))324 self.assertFalse(self.GetTranslateInfo()['can_translate_page'])325 def testChangeTargetLanguageAlwaysTranslate(self):326 """Tests that the change target language option works with always translate327 on reload.328 This test is motivated by crbug.com/37313.329 """330 self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())331 self._ClickTranslateUntilSuccess()332 # Select a different target language on translate info bar (French).333 self.ChangeTranslateToLanguage('French')334 translate_info = self.GetTranslateInfo()335 self.assertTrue('translate_bar' in translate_info)336 self.assertEqual('fr', translate_info['translate_bar']['target_lang_code'])337 # Select always translate Spanish to French.338 self.SelectTranslateOption('toggle_always_translate')339 # Reload the page and assert that the page has been translated to French.340 self.GetBrowserWindow(0).GetTab(0).Reload()341 self.WaitUntilTranslateComplete()342 translate_info = self.GetTranslateInfo()343 self.assertTrue(translate_info['page_translated'])344 self.assertTrue(translate_info['can_translate_page'])345 self.assertTrue('translate_bar' in translate_info)346 self.assertEqual('fr', translate_info['translate_bar']['target_lang_code'])347 def testSeveralLanguages(self):348 """Verify translation for several languages.349 This assumes that there is a directory of directories in the data dir.350 The directory is called 'translate', and within that directory there are351 subdirectories for each language code. Ex. a subdirectory 'es' with Spanish352 html files.353 """354 corpora_path = os.path.join(self.DataDir(), 'translate')355 corp_dir = glob.glob(os.path.join(corpora_path, '??')) + \356 glob.glob(os.path.join(corpora_path, '??-??'))357 for language in corp_dir:358 files = glob.glob(os.path.join(language, '*.html*'))359 lang_code = os.path.basename(language)360 logging.debug('Starting language %s' % lang_code)361 # Translate each html file in the language directory.362 for lang_file in files:363 logging.debug('Starting file %s' % lang_file)364 lang_file = self.GetFileURLForPath(lang_file)365 self._AssertTranslateWorks(lang_file, lang_code)366 def _CreateCrazyDownloads(self):367 """Doownload files with filenames containing special chars.368 The files are created on the fly and cleaned after use.369 """370 download_dir = self.GetDownloadDirectory().value()371 filename = os.path.join(self.DataDir(), 'downloads', 'crazy_filenames.txt')372 crazy_filenames = self.EvalDataFrom(filename)373 logging.info('Testing with %d crazy filenames' % len(crazy_filenames))374 def _CreateFile(name):375 """Create and fill the given file with some junk."""376 fp = open(name, 'w') # name could be unicode377 print >>fp, 'This is a junk file named %s. ' % repr(name) * 100378 fp.close()379 # Temp dir for hosting crazy filenames.380 temp_dir = tempfile.mkdtemp(prefix='download')381 # Filesystem-interfacing functions like os.listdir() need to382 # be given unicode strings to "do the right thing" on win.383 # Ref: http://boodebr.org/main/python/all-about-python-and-unicode384 try:385 for filename in crazy_filenames: # filename is unicode.386 utf8_filename = filename.encode('utf-8')387 file_path = os.path.join(temp_dir, utf8_filename)388 _CreateFile(os.path.join(temp_dir, filename)) # unicode file.389 file_url = self.GetFileURLForPath(file_path)390 downloaded_file = os.path.join(download_dir, filename)391 os.path.exists(downloaded_file) and os.remove(downloaded_file)392 pre_download_ids = [x['id']393 for x in self.GetDownloadsInfo().Downloads()]394 self.DownloadAndWaitForStart(file_url)395 # Wait for files and remove them as we go.396 self.WaitForAllDownloadsToComplete(pre_download_ids)397 os.path.exists(downloaded_file) and os.remove(downloaded_file)398 finally:399 shutil.rmtree(unicode(temp_dir)) # unicode so that win treats nicely.400 def testHistoryNotTranslated(self):401 """Tests navigating to History page with other languages."""402 # Build the history with non-English content.403 history_file = os.path.join(404 self.DataDir(), 'translate', 'crazy_history.txt')405 history_items = self.EvalDataFrom(history_file)406 for history_item in history_items:407 self.AddHistoryItem(history_item)408 # Navigate to a page that triggers the translate bar so we can verify that409 # it disappears on the history page.410 self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())411 self.NavigateToURL('chrome://history/')412 self.assertTrue(self.WaitForInfobarCount(0))413 self.assertFalse('translate_bar' in self.GetTranslateInfo())414 def testDownloadsNotTranslated(self):415 """Tests navigating to the Downloads page with other languages."""416 # Build the download history with non-English content.417 self._CreateCrazyDownloads()418 # Navigate to a page that triggers the translate bar so we can verify that419 # it disappears on the downloads page.420 self._NavigateAndWaitForBar(self._GetDefaultSpanishURL())421 self.NavigateToURL('chrome://downloads/')422 self.assertTrue(self.WaitForInfobarCount(0))423 self.assertFalse('translate_bar' in self.GetTranslateInfo())424 def testAlwaysTranslateInIncognito(self):425 """Verify that pages aren't auto-translated in incognito windows."""426 url = self._GetDefaultSpanishURL()427 self._NavigateAndWaitForBar(url)428 info_before_translate = self.GetTranslateInfo()429 self.assertTrue('translate_bar' in info_before_translate)430 self.SelectTranslateOption('toggle_always_translate')431 # Navigate to a page in incognito and verify that it is not auto-translated.432 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)433 self._NavigateAndWaitForBar(url, window_index=1)434 info_before_translate = self.GetTranslateInfo()435 self.assertTrue('translate_bar' in info_before_translate)436 self.assertFalse(info_before_translate['page_translated'])437 self.assertTrue(info_before_translate['can_translate_page'])438 self.assertEqual(self.before_translate,439 info_before_translate['translate_bar']['bar_state'])440 def testMultipleTabsAndWindows(self):441 """Verify that translate infobar shows up in multiple tabs and windows."""442 url = self._GetDefaultSpanishURL()443 def _AssertTranslateInfobarShowing(window_index=0, tab_index=0):444 """Navigate to a Spanish page in the given window/tab and verify that the445 translate bar shows up.446 """447 self._NavigateAndWaitForBar(448 url, window_index=window_index, tab_index=tab_index)449 info_before_translate = self.GetTranslateInfo(window_index=window_index,450 tab_index=tab_index)451 self.assertTrue('translate_bar' in info_before_translate)452 _AssertTranslateInfobarShowing()453 self.AppendTab(pyauto.GURL('about:blank'))454 _AssertTranslateInfobarShowing(tab_index=1)455 self.OpenNewBrowserWindow(True)456 _AssertTranslateInfobarShowing(window_index=1)457 self.AppendTab(pyauto.GURL('about:blank'), 1)458 _AssertTranslateInfobarShowing(window_index=1, tab_index=1)459 self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW)460 _AssertTranslateInfobarShowing(window_index=2)461 self.AppendTab(pyauto.GURL('about:blank'), 2)462 _AssertTranslateInfobarShowing(window_index=2, tab_index=1)463 def testNoTranslateInfobarAfterNeverTranslate(self):464 """Verify Translate Info bar should not stay on the page after opting465 Never translate the page"""466 url = self._GetDefaultSpanishURL()467 self._NavigateAndWaitForBar(url)468 self.SelectTranslateOption('never_translate_language')469 self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars'])470if __name__ == '__main__':...

Full Screen

Full Screen

translate.gypi

Source:translate.gypi Github

copy

Full Screen

1# Copyright 2013 The Chromium Authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4{5 'targets': [6 {7 # GN version: //components/translate/core/browser8 'target_name': 'translate_core_browser',9 'type': 'static_library',10 'dependencies': [11 '../base/base.gyp:base',12 '../base/base.gyp:base_i18n',13 '../google_apis/google_apis.gyp:google_apis',14 '../net/net.gyp:net',15 '../ui/base/ui_base.gyp:ui_base',16 '../url/url.gyp:url_lib',17 'components_resources.gyp:components_resources',18 'components_strings.gyp:components_strings',19 'data_use_measurement_core',20 'infobars_core',21 'language_usage_metrics',22 'pref_registry',23 'translate_core_common',24 'variations',25 ],26 'include_dirs': [27 '..',28 ],29 'sources': [30 # Note: sources list duplicated in GN build.31 'translate/core/browser/language_state.cc',32 'translate/core/browser/language_state.h',33 'translate/core/browser/page_translated_details.h',34 'translate/core/browser/translate_accept_languages.cc',35 'translate/core/browser/translate_accept_languages.h',36 'translate/core/browser/translate_browser_metrics.cc',37 'translate/core/browser/translate_browser_metrics.h',38 'translate/core/browser/translate_client.h',39 'translate/core/browser/translate_download_manager.cc',40 'translate/core/browser/translate_download_manager.h',41 'translate/core/browser/translate_driver.h',42 'translate/core/browser/translate_error_details.h',43 'translate/core/browser/translate_event_details.cc',44 'translate/core/browser/translate_event_details.h',45 'translate/core/browser/translate_experiment.cc',46 'translate/core/browser/translate_experiment.h',47 'translate/core/browser/translate_language_list.cc',48 'translate/core/browser/translate_language_list.h',49 'translate/core/browser/translate_manager.cc',50 'translate/core/browser/translate_manager.h',51 'translate/core/browser/translate_prefs.cc',52 'translate/core/browser/translate_prefs.h',53 'translate/core/browser/translate_script.cc',54 'translate/core/browser/translate_script.h',55 'translate/core/browser/translate_step.h',56 'translate/core/browser/translate_ui_delegate.cc',57 'translate/core/browser/translate_ui_delegate.h',58 'translate/core/browser/translate_url_fetcher.cc',59 'translate/core/browser/translate_url_fetcher.h',60 'translate/core/browser/translate_url_util.cc',61 'translate/core/browser/translate_url_util.h',62 ],63 'conditions': [64 ['use_aura==0', {65 'sources': [66 'translate/core/browser/translate_infobar_delegate.cc',67 'translate/core/browser/translate_infobar_delegate.h',68 ],69 }],70 ['OS == "mac"', {71 'sources': [72 'translate/core/browser/options_menu_model.cc',73 'translate/core/browser/options_menu_model.h',74 ],75 }],76 ],77 },78 {79 # GN version: //components/translate/core/common80 'target_name': 'translate_core_common',81 'type': 'static_library',82 'dependencies': [83 '../base/base.gyp:base',84 '../url/url.gyp:url_lib',85 ],86 'include_dirs': [87 '..',88 ],89 'sources': [90 # Note: sources list duplicated in GN build.91 'translate/core/common/language_detection_details.cc',92 'translate/core/common/language_detection_details.h',93 'translate/core/common/translate_constants.cc',94 'translate/core/common/translate_constants.h',95 'translate/core/common/translate_errors.h',96 'translate/core/common/translate_metrics.cc',97 'translate/core/common/translate_metrics.h',98 'translate/core/common/translate_pref_names.cc',99 'translate/core/common/translate_pref_names.h',100 'translate/core/common/translate_switches.cc',101 'translate/core/common/translate_switches.h',102 'translate/core/common/translate_util.cc',103 'translate/core/common/translate_util.h',104 ],105 },106 {107 # GN version: //components/translate/core/language_detection108 'target_name': 'translate_core_language_detection',109 'type': 'static_library',110 'dependencies': [111 'translate_core_common',112 '../base/base.gyp:base',113 '../url/url.gyp:url_lib',114 '../third_party/cld_2/cld_2.gyp:cld_2',115 ],116 'include_dirs': [117 '..',118 ],119 'sources': [120 # Note: sources list duplicated in GN build.121 'translate/core/language_detection/language_detection_util.cc',122 'translate/core/language_detection/language_detection_util.h',123 ],124 },125 ],126 'conditions': [127 ['OS != "ios"', {128 'targets': [129 {130 # GN version: //components/translate/content/browser131 'target_name': 'translate_content_browser',132 'type': 'static_library',133 'dependencies': [134 'translate_content_common',135 'translate_core_browser',136 '../base/base.gyp:base',137 '../content/content.gyp:content_browser',138 ],139 'include_dirs': [140 '..',141 ],142 'sources': [143 # Note: sources list duplicated in GN build.144 'translate/content/browser/content_translate_driver.cc',145 'translate/content/browser/content_translate_driver.h',146 ],147 },148 {149 # GN version: //components/translate/content/common150 'target_name': 'translate_content_common',151 'type': 'static_library',152 'dependencies': [153 'translate_core_common',154 'translate_core_language_detection',155 '../base/base.gyp:base',156 '../ipc/ipc.gyp:ipc',157 '../url/ipc/url_ipc.gyp:url_ipc',158 ],159 'include_dirs': [160 '..',161 ],162 'sources': [163 # Note: sources list duplicated in GN build.164 'translate/content/common/translate_messages.cc',165 'translate/content/common/translate_messages.h',166 ],167 },168 {169 # GN version: //components/translate/content/renderer170 'target_name': 'translate_content_renderer',171 'type': 'static_library',172 'dependencies': [173 'translate_content_common',174 'translate_core_common',175 'translate_core_language_detection',176 '../base/base.gyp:base',177 '../content/content.gyp:content_common',178 '../content/content.gyp:content_renderer',179 '../ipc/ipc.gyp:ipc',180 '../third_party/WebKit/public/blink.gyp:blink',181 '../third_party/cld_2/cld_2.gyp:cld_2',182 '../url/url.gyp:url_lib',183 '../v8/src/v8.gyp:v8',184 ],185 'include_dirs': [186 '..',187 ],188 'sources': [189 # Note: sources list duplicated in GN build.190 'translate/content/renderer/translate_helper.cc',191 'translate/content/renderer/translate_helper.h',192 ],193 },194 ],195 }],196 ['OS == "ios"', {197 'targets': [198 {199 # GN version: //components/translate/ios/browser200 'target_name': 'translate_ios_browser',201 'type': 'static_library',202 'include_dirs': [203 '..',204 ],205 'dependencies': [206 'translate_core_language_detection',207 'translate_core_browser',208 'translate_core_common',209 'translate_ios_injected_js',210 '../base/base.gyp:base',211 '../ios/web/ios_web.gyp:ios_web',212 '../url/url.gyp:url_lib',213 ],214 'sources': [215 'translate/ios/browser/ios_translate_driver.h',216 'translate/ios/browser/ios_translate_driver.mm',217 'translate/ios/browser/js_language_detection_manager.h',218 'translate/ios/browser/js_language_detection_manager.mm',219 'translate/ios/browser/js_translate_manager.h',220 'translate/ios/browser/js_translate_manager.mm',221 'translate/ios/browser/language_detection_controller.h',222 'translate/ios/browser/language_detection_controller.mm',223 'translate/ios/browser/translate_controller.h',224 'translate/ios/browser/translate_controller.mm',225 ],226 },227 {228 # GN version: //components/translate/ios/browser:injected_js229 'target_name': 'translate_ios_injected_js',230 'type': 'none',231 'sources': [232 'translate/ios/browser/resources/language_detection.js',233 'translate/ios/browser/resources/translate_ios.js',234 ],235 'link_settings': {236 'mac_bundle_resources': [237 '<(SHARED_INTERMEDIATE_DIR)/translate_ios.js',238 '<(SHARED_INTERMEDIATE_DIR)/language_detection.js',239 ],240 },241 'includes': [242 '../ios/web/js_compile_checked.gypi',243 ],244 },245 ],246 }],247 ],...

Full Screen

Full Screen

hardcoded_strings.py

Source:hardcoded_strings.py Github

copy

Full Screen

1from PyQt5.QtCore import QT_TRANSLATE_NOOP2## To translate this strings you must use qApp.translate('Mem',string) o mem.trHS.3QT_TRANSLATE_NOOP('Mem','Personal Management')4QT_TRANSLATE_NOOP('Mem','Cash')5QT_TRANSLATE_NOOP('Mem', 'Desconocido')6QT_TRANSLATE_NOOP('Mem', 'Initiating bank account')7QT_TRANSLATE_NOOP('Mem', 'Supermarket')8QT_TRANSLATE_NOOP('Mem', 'Restaurant')9QT_TRANSLATE_NOOP('Mem', 'Transfer. Origin')10QT_TRANSLATE_NOOP('Mem', 'Transfer. Destination')11QT_TRANSLATE_NOOP('Mem', 'Taxes. Returned')12QT_TRANSLATE_NOOP('Mem', 'Gasoline')13QT_TRANSLATE_NOOP('Mem', 'Leisure')14QT_TRANSLATE_NOOP('Mem', 'Teléfono')15QT_TRANSLATE_NOOP('Mem', 'Paysheet')16QT_TRANSLATE_NOOP('Mem', 'Televisión & Video & Cine')...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful