Languages
Every translation belongs to a language, identified by a three-letter
ISO 639-3 code. The languages query is the entry point when you
want to offer users a choice of language before a choice of translation.
List languages
- GraphQL
- cURL
- Ruby
- Node.js
- Response
query {
languages {
code
translationCount
}
}
curl https://bibleql.org/graphql \
-H "Authorization: Bearer $BIBLEQL_API_KEY" \
-H "Content-Type: application/json" \
--data '{"query":"query { languages { code translationCount } }"}'
require "bibleql"
client = BibleQL::Client.new(
api_key: ENV.fetch("BIBLEQL_API_KEY"),
api_url: "https://bibleql.org/graphql"
)
client.languages.each do |language|
puts "#{language.code}: #{language.translation_count} translations"
end
import { BibleQLClient } from "bibleql-js";
const client = new BibleQLClient({
apiKey: process.env.BIBLEQL_API_KEY!,
apiUrl: "https://bibleql.org/graphql",
});
const languages = await client.languages();
languages.forEach((l) => console.log(l.code, l.translationCount));
{
"data": {
"languages": [
{
"code": "swe",
"translationCount": 1
},
{
"code": "heb",
"translationCount": 1
},
{
"code": "spa",
"translationCount": 7
},
// ... 28 more
]
}
}
Each entry carries a code, a translationCount, and the translations themselves if you ask
for them:
query {
languages {
code
translationCount
translations {
identifier
name
note
}
}
}
That is usually all you need to populate a two-step language → translation picker in one request.
Language codes are not locales
A common source of confusion:
| Example | Used for | |
|---|---|---|
| Language code | spa, eng, deu | The language field on a translation |
| Translation identifier | spa-rv1909, eng-web | The translation argument |
| Documentation locale | es, en | Which language this site is written in |
Only the middle row is accepted by query arguments. Passing spa where a translation
identifier is expected returns a not-found error.
Human-readable names
code is a machine identifier, not a label to show users. For display, read languageName on
a translation:
query {
translations {
identifier
language
languageName
name
}
}
languageName is more specific than the code where it needs to be — English translations
distinguish English, English (UK) and English (US) even though all three share the eng
code.
translationCount reflects what is loaded right now. Query it rather than hard-coding a
number, which will go stale as translations are added.