• Discovered: Mar 25, 2024. 17:40 CSS path using Firefox’s inspector: ul.locales:nth-child(2) > li:nth-child(4) > a:nth-child(1) is list of localizations for a SUMO KB article https://support.mozilla.org/en-US/kb/troubleshoot-mode-thunderbird/show_translations i.e. en-US./kb/<slug>/show_translations
  • NOT TESTED (I’ll write a follow up blog post once I have working code) –>The following is inspired by my code from 7 years ago (!) that tested SUMO KB redirects as part of our unsuccessful migration from Kitsune to Lithium.

The better way (discovered after the kludgy way)

    1. one liner using the unique CSS class name for locale links which in this case is translated_locale:
page = mechanize.get ARGV[0]
results  = page.css('.translated_locale').map{ |link| link['href']}
    1. And then from: https://github.com/rtanglao/rt-li-sumo-redirects/blob/master/test-firefox-focus-android-redirects.rb open the link to see if there is a redirect.
      Net::HTTP.start(from_uri.host, from_uri.port,
                    :use_ssl => from_uri.scheme == 'https') do |http|
      request = Net::HTTP::Get.new from_uri.request_uri
      request.basic_auth userid, password
      response = http.request request # Net::HTTPResponse object
      response_uri = response['location']

Kludgy initial way

page  = mechanize.get 'https://support.mozilla.org/en-US/kb/troubleshoot-mode-thunderbird/show_translations'
page.css('.translated_locale').each do |l|
irb(main):201:1*   puts l.css('@href').first.value
irb(main):202:0> end


Leave a comment on github