Skip to content

Commit

Permalink
fix multilingual support for AG backend
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Apr 17, 2024
1 parent eba6251 commit fb04e78
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
20 changes: 1 addition & 19 deletions lib/goo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,7 @@ def self.add_sparql_backend(name, *opts)
@@sparql_backends[name][:backend_name] = opts[:backend_name]
@@sparql_backends.freeze
end

def self.test_reset
if @@sparql_backends[:main][:query].url.to_s["localhost"].nil?
raise Exception, "only for testing"
end
@@sparql_backends[:main][:query]=Goo::SPARQL::Client.new("http://localhost:9000/sparql/",
{protocol: "1.1", "Content-Type" => "application/x-www-form-urlencoded",
read_timeout: 300,
redis_cache: @@redis_client })
end

def self.main_lang
@@main_lang
end

def self.main_lang=(value)
@@main_lang = value
end


def self.use_cache=(value)
@@use_cache = value
set_sparql_cache
Expand Down
8 changes: 4 additions & 4 deletions lib/goo/sparql/mixins/solution_lang_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def models_unmapped_to_array(m)

def set_value(model, predicate, value, &block)
language = object_language(value)

if requested_lang.eql?(:ALL) || !literal?(value) || (language_match?(language) && can_add_new_value?(model,predicate, language))
block.call
end
Expand Down Expand Up @@ -102,9 +102,9 @@ def language_match?(language)
# no_lang means that the object is not a literal
return true if language.eql?(:no_lang)

return requested_lang.include?(language) if requested_lang.is_a?(Array)
return requested_lang.include?(language.upcase) if requested_lang.is_a?(Array)

language.eql?(requested_lang)
language.upcase.eql?(requested_lang)
end

def literal?(object)
Expand All @@ -113,7 +113,7 @@ def literal?(object)

def store_objects_by_lang(id, predicate, object, language)
# store objects in this format: [id][predicate][language] = [objects]
return if requested_lang.is_a?(Array) && !requested_lang.include?(language) && !language.eql?('@none')
return if requested_lang.is_a?(Array) && !requested_lang.include?(language.upcase) && !language.eql?('@none')

language_key = language.downcase

Expand Down

0 comments on commit fb04e78

Please sign in to comment.