Skip to content

Commit

Permalink
Remove language detection through cld3 (mastodon#17478)
Browse files Browse the repository at this point in the history
* Remove language detection through cld3

* Update app/helpers/languages_helper.rb

Co-authored-by: Yamagishi Kazutoshi <ykzts@desire.sh>

Co-authored-by: Yamagishi Kazutoshi <ykzts@desire.sh>
  • Loading branch information
2 people authored and stsecurity committed Oct 17, 2023
1 parent 2ff7ac4 commit 5748c82
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
8 changes: 0 additions & 8 deletions app/lib/link_details_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/helpers/languages_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 5748c82

Please sign in to comment.