Retrieving all translations via Kirby Query Language (kql)

There is actually a way to retrieve all translations via the core API and there is a way to retrieve the translations in the Kirby front-end via the site->translations() API.

Yet, trying to use the site’s translations function via the kql API (query: site.translations), it responds with the error, that this function is not allowed in the context of the API.

I’m able to run query: kirby.translations but I’m not sure what I’m looking at here with that result.

    "translations": [
      "bg",
      "ca",
      "cs",
      "da",
      "de",
      "el",
      "en",
      "es_419",
      "es_ES",
      "fa",
      "fi",
      "fr",
      "hu",
      "id",
      "it",
      "ko",
      "lt",
      "nb",
      "nl",
      "pl",
      "pt_BR",
      "pt_PT",
      "ru",
      "sk",
      "sv_SE",
      "tr"
    ]

So, my question is, is there even a way to get all translations via the kql plugin?

To clarify I don’t mean a language version of the page content, but the static translation strings.

You probably mean https://getkirby.com/docs/reference/objects/language/translations?

That one sadly gives me null when used in a kql query. X-Language header is set and the language I try has a couple of strings in translations of the language file.

I tried this:

"translations": {
    "query": "language",
    "select": {
      "translations": true
  }
}

and this:

"translations": {
    "query": "language.translations"
}

Which both should query the identical property and thus yield the same results.

Unless you have another idea, I guess it’s probably not implemented in the kql plugin (?) and will then therefore ask on the GitHub repo.

Yes, testing that query myself I get an error “The method “Kirby\Cms\Language::translations()” is not allowed in the API context” and looking at the source code, that method is nowhere in the allowed methods.

Thanks for digging into the code for me. Didn’t really take that effort as I have shallow knowledge of PHP.

I created an issue on GitHub.