Home » Php » php – Non-translated properties of entity with TranslateBehaviour

php – Non-translated properties of entity with TranslateBehaviour

Posted by: admin July 12, 2020 Leave a comment

Questions:

We’re building an app that is internationalised in Cakephp 3.0.8 , and with all static stuff everything is fine, but we’re having some issues with the translation of database contents.

In the process of building an interface for our translators to translate content in the tables, it would be awesome to be able to have an interface with something like:

+---------+---------+--------+---------+---------+
| English | Danish | German | Spanish | Swedish |
+---------+---------+--------+---------+---------+
| Save | Gem | ____ | ____ | ____ |
| Edit | Rediger | ____ | ____ | ____ |
+---------+---------+--------+---------+---------+

so the translators can start working on the missing translations. Point is that all the strings that have missing translations should just be shown here

To achieve this, it would be nice to be able to get

  1. All fields in a table, that should be translated
  2. Translations for the already translated fields

But especially 1) seems quite hard, or are we missing something?

We’re using the core TranslationBehaviour (link)

How to&Answers:

Pasting the answer on behalf of the original question author:

Allright, I got the answer for 1) from #cakephp @ Freenode.org. The following will output the correct fields that should be translated:

$this->TableName->behaviors()->get('Translate')->config('fields');

Translation for already translated fields can be retrieved by using $table->find('translations')