Skip to content

Commit

Permalink
change the language filter to take only one language
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Mar 16, 2022
1 parent 1108250 commit 7c9aa72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/goo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ module Goo
@@resource_options = Set.new([:persistent]).freeze

# Define the languages from which the properties values will be taken
# It choose the first language that match otherwise return all the values
@@main_languages = %w[en]

@@configure_flag = false
@@sparql_backends = {}
@@model_by_name = {}
Expand Down
8 changes: 6 additions & 2 deletions lib/goo/sparql/mixins/solution_lang_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ def languages_values_to_set(language_values, no_lang_values)
matched_lang, not_matched_lang = matched_languages(language_values, no_lang_values)
if !matched_lang.empty?
main_lang = Array(matched_lang[:'0']) + Array(matched_lang[:no_lang])
secondary_languages = matched_lang.select { |key| key != :'0' && key != :no_lang }.sort.map { |x| x[1] }.flatten
values = main_lang + secondary_languages
if main_lang.empty?
secondary_languages = matched_lang.select { |key| key != :'0' && key != :no_lang }.sort.map { |x| x[1] }
values = secondary_languages.first
else
values = main_lang
end
elsif !not_matched_lang.empty?
values = not_matched_lang
end
Expand Down

0 comments on commit 7c9aa72

Please sign in to comment.