Translated Fields
Several resources in the Moloni ON API (document types, countries, currencies, and languages) store their names and descriptions in multiple languages. These resources expose a translations array with one entry per language, and a set of shorthand fields that return the translation for a specific language directly.
How it works
Resources with translated content follow this pattern:
- A
translationsarray holds every available translation (one entry per language, each with alanguageId). - Shorthand fields like
title,titlePlural,name,description,notes, andabbreviationare convenience aliases that return the value for the language specified inoptions.defaultLanguageId. - If
defaultLanguageIdis omitted, the shorthand fields returnnull.
Fetching available languages
Use the languages query to get all supported language IDs:
query {
languages {
data {
languageId
name
iso3166
}
}
}
Common language IDs:
languageId | Language |
|---|---|
| 1 | Portuguese (PT) |
| 2 | English |
Using defaultLanguageId
Pass defaultLanguageId inside the options argument of any query that supports it:
query {
documentTypes(options: { defaultLanguageId: 2 }) {
data {
documentTypeId
apiCode
title # English name, e.g. "Invoice"
titlePlural # English plural, e.g. "Invoices"
}
}
}
Without defaultLanguageId, title and titlePlural are null. To always get a name regardless of language preference, query the full translations array instead:
query {
documentTypes {
data {
documentTypeId
apiCode
translations {
languageId
title
titlePlural
}
}
}
}
Resources that support translated fields
| Resource | Shorthand fields |
|---|---|
| Document Types | title, titlePlural |
| Countries | title, notes |
| Currencies | description, abbreviation |
| Languages | name |
All of these accept defaultLanguageId in their options argument and expose a translations array for the full data.
Next steps
- Document Types: Use translated document type names in your app
- Customers: Work with country and currency references on customer records
- API Reference: Explore all types with translatable fields