samvera / questioning_authority

Question your authorities
Other
54 stars 30 forks source link

No way to display labels in multiple languages #170

Open ghost opened 6 years ago

ghost commented 6 years ago

There seems to be no way to give labels in multiple languages. It's a problem when the underlying vocabulary is a skos vocabulary where preflabels have langtags. We can not adapt the display to the user's language preferences. Or, should we create a yaml file per language with a suffix and adapt the client code? Or replace the terms with i18n keys and put the labels in the internationalization files by adapting the code?

elrayle commented 5 years ago

@j-dornbusch I'm wondering if you can expand on the issue you are having with an example of a label that is not translating.

Here are a few observations around language processing in QA.

Authority language data comes in several varieties:

authority defines literals with language tags for a single label predicate

This allows for a search with the query string in the specified language and returns results in the requested language

Examples:

https://lookup.ld4l.org/authorities/search/linked_data/agrovoc_ld4l_cache?q=Milch&maxRecords=4&lang=de

https://lookup.ld4l.org/authorities/search/linked_data/getty_aat_ld4l_cache?q=karte&maxRecords=4&lang=de

authority defines alternate language literals in alternate label

This allows for a search with the query string in the specified language, but the results will be returned for the primary language only (almost always English)

Example:

https://lookup.ld4l.org/authorities/search/linked_data/oclcfast_ld4l_cache?q=twain%20marek&maxRecords=4

authority defines language variants linked via a bnode

QA can search other direct predicates (as seen in previous example), but does not at this time support cascading search to a bnode value. In this case, you cannot search using a query string in the alternate language. It will return 0 results.

<http://id.loc.gov/authorities/subjects/sh85118553> <http://www.loc.gov/mads/rdf/v1#hasCloseExternalAuthority> <http://d-nb.info/gnd/4066562-8> . 
<http://d-nb.info/gnd/4066562-8> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.loc.gov/mads/rdf/v1#Authority> . 
<http://d-nb.info/gnd/4066562-8> <http://www.loc.gov/mads/rdf/v1#authoritativeLabel> "Wissenschaft"@de . 

authority defines language variants linked via a bnode and marked with the wrong language tag

http://id.loc.gov/authorities/names/n79021164.nt

authority has no language support

There are more than a few authorities where the raw data does not include language tags on the literals.

A few other thoughts

If you have a specific authority you are trying to work with, we can look into what the data supports and whether an indexing change would allow for language search.

QA can support many more authorities than what comes with QA. Many of the examples here are from these additional authorities. You can see other supported linked data authorities at https://github.com/ld4p/linked_data_authorities.

ghost commented 5 years ago

@elrayle I am sorry to answer after such a long delay. We have created file based controlled vocabularies derived from Skos thesaurus. So the 'prefLabels' come with RDF langtags. The generated YAML file looks like this :

terms:
  - id: http://data.ehess.fr/thes/airecult/aire8
    term:
      - '"Asie"@fr'
      - '"Asia"@en'
  - id: http://data.ehess.fr/thes/airecult/aire13
    term:
      - '"Britanniques (études)"@fr'
      - '"British (studies)"@fr'
  - id: http://data.ehess.fr/thes/airecult/aire26
    term:
      - '"Japon"@fr'
      - '"Japan"@en'
  - id: http://data.ehess.fr/thes/airecult/aire2
    term:
      - '"Allemandes (études)"@fr'
      - '"German (studies)"@en'
  - id: http://data.ehess.fr/thes/airecult/aire20
    term:
      - '"Europe sud-orientale"@fr'
# etc

A wrapper service is then needed to filter the appropriate language (and of course a helper or a renderer to remove the langtag before displaying the label).

def select_all_options(locale = :fr)
    get_authority.all.map do |element|
      [apply_language_preference(element[:label], locale), element[:id]]
    end.sort_by {|element| element.first.downcase}
end

def get_authority
    authority = Qa::Authorities::Local.subauthority_for(@vocabulary_identifier) unless authority
end