From 1a4159ac71ce616420130f5177bb46d7e4c706f2 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 8 Feb 2022 02:41:17 +0100 Subject: [PATCH] Remove language detection through cld3 (#17478) * Remove language detection through cld3 * Update app/helpers/languages_helper.rb Co-authored-by: Yamagishi Kazutoshi Co-authored-by: Yamagishi Kazutoshi --- app/lib/link_details_extractor.rb | 8 -------- spec/helpers/languages_helper_spec.rb | 6 +++--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app/lib/link_details_extractor.rb b/app/lib/link_details_extractor.rb index cf273e4967d59e..6fa4338c70f4a1 100644 --- a/app/lib/link_details_extractor.rb +++ b/app/lib/link_details_extractor.rb @@ -232,14 +232,6 @@ def valid_url_or_nil(str, same_origin_only: false) nil end - def valid_locale_or_nil(str) - return nil if str.blank? - - code, = str.split(/_-/) # Strip out the region from e.g. en_US or ja-JA - locale = ISO_639.find(code) - locale&.alpha2 - end - def link_tag(name) document.xpath("//link[@rel=\"#{name}\"]").map { |link| link['href'] }.first end diff --git a/spec/helpers/languages_helper_spec.rb b/spec/helpers/languages_helper_spec.rb index 6db617824db8f8..b455cee33d1a3a 100644 --- a/spec/helpers/languages_helper_spec.rb +++ b/spec/helpers/languages_helper_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' describe LanguagesHelper do - describe 'the HUMAN_LOCALES constant' do - it 'includes all I18n locales' do - expect(described_class::HUMAN_LOCALES.keys).to include(*I18n.available_locales) + describe 'the SUPPORTED_LOCALES constant' do + it 'includes all i18n locales' do + expect(Set.new(described_class::SUPPORTED_LOCALES.keys + described_class::REGIONAL_LOCALE_NAMES.keys)).to include(*I18n.available_locales) end end