Overview
I had the opportunity to get a list of untranslated nodes in Drupal, so this is a personal note for future reference.
Method
There are various approaches, but this time I use JSON:API.
Let’s assume the master language is Japanese (ja) and the translation language to add is English (en).
Using JSON:API, for example, for a taxonomy called collection, you can retrieve it with the following:
https://xxx/jsonapi/taxonomy_term/collection
Additionally, by adding /en as follows, if a translation node exists, that information is returned.
https://xxx/en/jsonapi/taxonomy_term/collection
In this case, if a translation node exists, attributes/langcode becomes en, but for nodes without translations, it remains ja.
{
"jsonapi": {
"version": "1.0",
"meta": {
"links": {
"self": {
"href": "http://jsonapi.org/format/1.0/"
}
}
}
},
"data": [
{
"type": "taxonomy_term--collection",
"id": "1e3d1e6f-5178-4980-96bd-7b045f2cc66e",
"links": {
"self": {
"href": "https://xxx/en/jsonapi/taxonomy_term/collection/1e3d1e6f-5178-4980-96bd-7b045f2cc66e?resourceVersion=id%3A19"
}
},
"attributes": {
"drupal_internal__tid": 19,
"drupal_internal__revision_id": 19,
"langcode": "en",
"revision_created": null,
"revision_log_message": null,
...
Using this property, when a language code different from the specified language is contained in langcode, it can be extracted as a node without a translation for that language.
Note that based on the JSON:API specification, pagination can be performed using page queries as follows. This is used for bulk data retrieval.
https://xxx/en/jsonapi/taxonomy_term/collection?page[offset]=50&page[limit]=50
Summary
There may be better methods, but I hope this serves as a useful reference.