Class: Qa::LinkedData::LanguageService
- Inherits:
-
Object
- Object
- Qa::LinkedData::LanguageService
- Defined in:
- app/services/qa/linked_data/language_service.rb
Constant Summary collapse
- WILDCARD =
'*'.freeze
Class Method Summary collapse
-
.literal_has_language_marker?(literal) ⇒ Boolean
True if literal has a language tag; otherwise, false.
-
.preferred_language(user_language: nil, authority_language: nil) ⇒ Array<Symbol>
The selected language(s) normalized as an array of symbols (e.g. [:en, :fr]).
Class Method Details
.literal_has_language_marker?(literal) ⇒ Boolean
Returns true if literal has a language tag; otherwise, false.
23 24 25 26 |
# File 'app/services/qa/linked_data/language_service.rb', line 23 def literal_has_language_marker?(literal) return false unless literal.respond_to?(:language) literal.language.present? end |
.preferred_language(user_language: nil, authority_language: nil) ⇒ Array<Symbol>
Note:
Precedence from high to low:
-
user_language (with URL parameter preferred over URL header)
-
authority_language (defined in authority config)
-
site default_language (defined in QA initializer)
Returns the selected language(s) normalized as an array of symbols (e.g. [:en, :fr]).
15 16 17 18 19 |
# File 'app/services/qa/linked_data/language_service.rb', line 15 def preferred_language(user_language: nil, authority_language: nil) return normalize_language(user_language) if user_language.present? return normalize_language() if .present? normalize_language(Qa.config.default_language) end |