Skip to content

Support for fallback languages in tw_get_label() and tw_get_description() / consider "default for all languages" #11

@giocomai

Description

@giocomai

This has become more relevant with the introduction of language-agnostic labels. E.g. Q85518537 does not have a label in English, but only in "default for all languages". This can be retrieved through the API (and tw_get_label()) by setting the language as "mul".

Desidered behaviour

It is possible to have a fallback language, when no label is available in the preferred language. E.g. the following should be possible:

tw_get_label(id = "Q85518537", language = c("en", "mul"))

If the label for "en" is not available, label for "mul" is tentatively retrieved.

Ideally, this should be done efficiently, with a single call to the API, but at a minimum it should work even if inefficiently.

Steps

  • Turn tw_get_label() and tw_get_description() in wrapper functions around a generic tw_get_info() (or similar) to deduplicate code
  • if language has length > 1, then before returning the value, if any of the labels is not available in the first language, it should check for fallback languages, and return the most complete set of results available, maintaining preference
  • if this can be achieved efficiently, then c("en", "mul") should likely become the new default language
  • issues related to the new "default for all languages" should be added to the readme
  • documentation to tw_get_label() and tw_get_description() should be updated accordingly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions