Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
322 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Service to determine which language to use for sorting and filtering. | ||
module Qa | ||
module LinkedData | ||
class LanguageService | ||
class << self | ||
def preferred_language(user_language: nil, authority_language: nil) | ||
return normalize_language(user_language) if user_language.present? | ||
return normalize_language(authority_language) if authority_language.present? | ||
normalize_language(Qa.config.default_language) | ||
end | ||
|
||
def literal_has_language_marker?(literal) | ||
return false unless literal.respond_to?(:language) | ||
literal.language.present? | ||
end | ||
|
||
private | ||
|
||
# Normalize language | ||
# @param [String | Symbol | Array] language for filtering graph (e.g. "en" OR :en OR ["en", "fr"] OR [:en, :fr]) | ||
# @return [Array<Symbol>] an array of languages encoded as symbols (e.g. [:en] OR [:en, :fr]) | ||
def normalize_language(language) | ||
return language if language.blank? | ||
language = [language] unless language.is_a? Array | ||
language.map(&:to_sym) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<http://id.worldcat.org/fast/530369> <http://purl.org/dc/terms/identifier> "530369" . | ||
<http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#prefLabel> "buttermilk"@en | ||
<http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#prefLabel> "Babeurre"@fr | ||
<http://id.worldcat.org/fast/530369> <http://www.w3.org/2004/02/skos/core#prefLabel> "Buttermilch" | ||
<http://id.worldcat.org/fast/5140> <http://purl.org/dc/terms/identifier> "5140" . | ||
<http://id.worldcat.org/fast/5140> <http://www.w3.org/2004/02/skos/core#prefLabel> "dried milk"@en | ||
<http://id.worldcat.org/fast/5140> <http://www.w3.org/2004/02/skos/core#prefLabel> "lait en poudre"@fr | ||
<http://id.worldcat.org/fast/5140> <http://www.w3.org/2004/02/skos/core#prefLabel> "getrocknete Milch"@de | ||
<http://id.worldcat.org/fast/557490> <http://purl.org/dc/terms/identifier> "557490" . | ||
<http://id.worldcat.org/fast/557490> <http://www.w3.org/2004/02/skos/core#prefLabel> "condensed milk"@en | ||
<http://id.worldcat.org/fast/557490> <http://www.w3.org/2004/02/skos/core#prefLabel> "Kondensmilch"@de |
Oops, something went wrong.