# Translate rows in acl acos in cakephp 4.2

**URL:** <https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382>\
**Category:** Need Help\
**Created:** [July 20, 2023, 3:29pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382 "2023-07-20T15:29:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [July 20, 2023, 3:29pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/1 "2023-07-20T15:29:00Z")

</div>

I need to translate tha acl acos to spanish so that the user can select these to grant permissions to another users, how can I do that?

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [August 15, 2023, 6:00pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/2 "2023-08-15T18:00:12Z")

</div>

Please, can you help me with this? I added the translate behavior and used the shadow table strategy in AcosTable and when I execute the command bin/cake acl\_extras aco\_sync it saves all the acos in acos table and in acos\_translations table, but in acos table all the fields have null values and in acos\_translations are not translated, how can I solve that?

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [September 11, 2023, 8:52pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/3 "2023-09-11T20:52:34Z")

</div>

Can you help me with this? I need to solve this as soon as possible and don’t know how to solve it.  
Thank you very much for your help.

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [September 12, 2023, 2:49pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/4 "2023-09-12T14:49:20Z")

</div>

At least give me an answer and I will stop asking, I need to know if it’s possible or not.

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [September 12, 2023, 3:04pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/5 "2023-09-12T15:04:09Z")

</div>

I don’t have an exact answer for you because I have never used the ACL plugin for CakePHP.  
But in the end ACL in general is just one way how you can implement authorization in your app.

And if you need something that may or may not be out of scope (or not obvious in the docs or to somone else inhere) then you as a developer need to find a way to solve this problem.  
It may very well be needed to fork the acl plugin and adjust it to your needs so that the correct acos are loaded accordingly.

Authorization alone can get complicated very quickly, and the fact that you now have translatable permissions multiplies that complexity again. So just by the information you have given this can’t be answered appropriately in my honest opinion.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [September 12, 2023, 3:23pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/6 "2023-09-12T15:23:53Z")

</div>

It’s not actually clear to me whether your problem is that the values are wrong in the database, or they are correct in the database but you’re not getting the translations when you load them in your code.

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [September 12, 2023, 3:47pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/7 "2023-09-12T15:47:44Z")

</div>

When I execute bin/cake acl\_extras aco\_sync and have the acos\_translations table with the TranslateBehavior added to the AcosTable class in namespace Acl\Model\Table, in acos saves all the records for my controllers and actions but with null values and in acos\_translations the values are the correct ones but in english, they are not translated to spanish (locale: es\_ES), maybe I have to create a MyAcosTable in App\Model\Table, is that correct?

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [September 12, 2023, 4:07pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/8 "2023-09-12T16:07:40Z")

</div>

Like Kevin, I’ve never used ACL, so I have no idea what the problem might be for you. Just pointing out that the question is vaguely worded and includes no relevant code or data, so that might be a contributing factor to getting a response.

Do you have translations for those strings _somewhere_, in a locale file or the like?

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [September 12, 2023, 4:17pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/9 "2023-09-12T16:17:05Z")

</div>

No, those strings are not in the code, there is no `__('text')` that I want to translate, is everything in acos table, that’s why I am not posting any code

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [September 12, 2023, 4:34pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/10 "2023-09-12T16:34:42Z")

</div>

Where, then, are you expecting the translations to come from?

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [September 12, 2023, 4:45pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/11 "2023-09-12T16:45:09Z")

</div>

From acos table, I don’t know how it works the TranslateBehavior

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [September 12, 2023, 5:23pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/12 "2023-09-12T17:23:35Z")

</div>

But how do you expect they get into that table? If the answer is “from the bake process”, then my question becomes how do you expect the bake process to get them? Translations don’t materialize from nowhere, and there’s no connection from any standard Cake functionality to anything like Google Translate. You need to provide the initial translation, somehow.

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [September 12, 2023, 5:58pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/13 "2023-09-12T17:58:58Z")

</div>

Last month I could save the acos and the acos\_translations with bake process and the records in acos had null values and the records in acos\_translations were in english language, right now the bake process is not saving the translations, it saves only the acos records.  
How does it work the translatebehavior in cakephp 4.4?  
I updated the version with composer update, maybe in cakephp 4.2 works in a different way than cakephp 4.4.

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [September 12, 2023, 8:28pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/14 "2023-09-12T20:28:20Z")

</div>

I will change the Acl for Authorization plugin, I will investigate how to use it, because is giving me too many problems.  
Is it too much to ask how to configure the Authorization plugin dinamically?

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [September 12, 2023, 10:19pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/15 "2023-09-12T22:19:59Z")

</div>

You’ll certainly need to give specifics about what you mean by that, and it should go into a new topic, not extend this one where nobody will likely see it.

---

<div class="post-metadata">

**Author:** ![thomasg](https://avatars.discourse-cdn.com/v4/letter/t/9d8465/32.png) [@thomasg](https://discourse.cakephp.org/u/thomasg)\
**Post date:** [September 13, 2023, 2:48am UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/16 "2023-09-13T02:48:15Z")

</div>

Why don’t you use cakedc Users plugin?

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [September 13, 2023, 9:51pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/17 "2023-09-13T21:51:10Z")

</div>

I will use the Acl plugin with the TranslateBehavior added with ShadowStrategy, is there a way to translate automatically the field alias of acos table and put that translation in a form control to save it in the table acos\_translations, maybe with google or another translator?

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [September 13, 2023, 9:59pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/18 "2023-09-13T21:59:08Z")

</div>

You can get yourself a Google API key, and look up how to access their APIs, and call them as appropriate from your own code. Is there a Cake plugin that does that for your acos table? Almost certainly not.

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [September 13, 2023, 10:03pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/19 "2023-09-13T22:03:29Z")

</div>

Thank you @Zuluru for the answer, I will look how to add the google api in cakephp

---

<div class="post-metadata">

**Author:** ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)\
**Post date:** [September 14, 2023, 2:56pm UTC](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382/20 "2023-09-14T14:56:11Z")

</div>

How can I do `$this->Acos->find('all', ['locale' => 'es'])->count()` and only have the count of the acos\_translations table and not the acos table? Because the acos\_translations is empty and the acos table has 118 records, I want to have the count = 0 of acos\_translations.

[Next page](https://discourse.cakephp.org/t/translate-rows-in-acl-acos-in-cakephp-4-2/11382.md?page=2)
