Translation unavailable message

Hi there,

On a multilingual site, I want to show a message at the top of each page that contains fields not yet translated. Is there a recommended approach to this? It’s not a huge site, so I would be fine having to manually switch something in the Panel rather than a completely automatic detection.

I found this solution, but it only works for pages that have no translation at all. Unfortunately, such a verification switches values as soon as you translate one single field, so it doesn’t work for my use case (I need to show the message unless all content is translated).

Alternatively, like I said, I would be more than happy with manually switching some setting (e.g. a toggle field) on each page that has untrasnlated content. Here the question would be: is it possible to hide that toggle field in the default language using the Conditional fields (when)?

Cheers!

You could loop through the translation content ($page->translation($languageCode)->content())and check if all fields are filled and if not, add them to an array. You could even go so far as to check if the field is also empty or not in the default language.

Thanks! That should be a solid solution in many cases, but I think it’s overkill in mine.

Also worth noting: actually the pages concerned are composed using a blocks fields and, as you may already know, what happens when you start editing a new language is that Kirby copies all the content from the default language and fills it into the new language. So even if the user has only translated one block, going through $page->translation($languageCode)->content() will detect no empty fields, and thus will think that the page is fully translated. I would have to compare the actual content of each field and check if it’s the exact same as in the default language. And anyway, in other languages you can delete blocks and add new one, so you can quickly loose sync and it becomes impossible to keep track of the level of translation.

Anyway, I think I prefer to stick to the manual approach. It can easily be solved with a “Show unfinished translation message?” toggle field on each page. Only thing I’m missing to make it more elegant is to hide the toggle in the default language. Can that be done?