OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform Task priority translation

This topic contains 14 replies, has 3 voices, and was last updated by  William Radi 5 years, 10 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #37151

    William Radi
    Participant

    Hello there!

    Another translation problem:

    I’m trying to create a new task, and there is a choice field called Priority, with the options High, Normal and Low:

    Task priority

    I need to translate this options to pt_BR.
    I tried to find some key, but I only discovered that it’s an entity…

    So, do I need to alter some table? And/or create some files? Where?

    Thaks, guys! :D

Viewing 14 replies - 1 through 14 (of 14 total)
  • Author
    Replies
  • #37152

    Andrey Yatsenko
    Moderator

    Currently task priority entity is not translatable, seems there is an error.

    As there is no any CRUD operations for this entity I recommend you just create form type extension to this field to make choice options translatable with translatable_options = true and then translate it as regular at yml files, it will be the rouge by easiest way.

    #37153

    William Radi
    Participant

    Oh.. ok
    Understand (half)..

    But, which files should I create and inside which folders and how can I make choice options translatable?
    Like, where to put the translatable_options = true?
    What to put inside the Build method?

    Can you give me an exemple code, please (of form type and yml)? :D

    #37154

    Andrey Yatsenko
    Moderator

    You need to create form type extension, not a form type, there is documentation about it
    https://symfony.com/doc/2.8/form/create_form_type_extension.html

    And register it at services.yml

    #37155

    William Radi
    Participant

    Thanks for the explanation!

    Doing it, I tourn the options translatable. But to effectively translate, I need a key, like ‘oro.task.type. …”, and than, translate it in a messages.pt_BR.yml file, right?

    Where do I set them and which name can I use?

    Thanks again!

    #37156

    Andrey Yatsenko
    Moderator

    The keys are original english labels, like Normal

    #37158

    William Radi
    Participant

    Didn’t work =/

    My form type extension is like yours, I only changed the namespace…

    Service too, just changed class:

    And than, I add a messages.pt_BR.yml file:

    #37159

    William Radi
    Participant

    And my localhost/task/create stil like that

    #37160

    William Radi
    Participant

    Tried here to run

    and

    Put

    In a entities.pt_BR.yml file, I cleared the cache, but nothing again..

    #37161

    William Radi
    Participant

    I don’t know if it helps, but I noticed that these changes I made, had an effect on the datagrid…

    If I try to edit the priority level directly on the datagrid (localhost/task), it pops up in portuguese:
    Task datagrid

    • This reply was modified 5 years, 11 months ago by  William Radi.
    #37163

    Viacheslav Bemza
    Participant

    Hello, William Radi

    Hm, it’s strange. I tried to use your code and see that the options are translated.
    It looks like your form type extension does not work.
    You can simply check it using xdebug or just add die(); function in form type extension.

    Did you register your TaskBundle? Also, check that you load service definitions using DependencyInjection’s extension.

    #37164

    William Radi
    Participant

    Hi, Viacheslav! :D

    You’re right! I didn’t add my service.yml to DependencyInjection.
    I added it and because of an error message I found a typo in service.yml file.

    I corrected it, but still not working.. I added the die() inside the buildForm method, but my form doesn’t stop.. And without the die(), it continue not translated… :(

    my codes again:
    Type extension:

    Dependency injection:

    services.yml:

    #37165

    Andrey Yatsenko
    Moderator

    Hi William,

    Just checked your code,
    there are several issues with imports (“use” statements), for example, you forgot to import TaskType to TaskTypeTypeExtension everything else looks fine.

    Here is working solution based on your code, I just added imports and translation for “en” to Normal option.
    https://gist.github.com/anyt/04c5ebd9576b58edf17f9ef0ab5591e1

    Here is a screenshot, how it looks like
    Task Priority translation

    After creating a bundle I just run app/console oro:translation:load --env=prod to load new translation and everything works.

    #37166

    William Radi
    Participant

    Hi, Andrey!

    After a lot of tests, I tried your code in a new instance of Oro. Without any other bundle, and it worked!
    Thanks a lot for your code, time and patience! :)

    Well, now it’s just to find the reason.. hehe

    Do you have any tips to me?

    Thanks again!

    #37167

    William Radi
    Participant

    Hi, again! lol

    The problem is that I already had a form extending of Oro task… My fault!

    So, I added the builder inside to my existing form and the field was translate!

    Thanks!

Viewing 14 replies - 1 through 14 (of 14 total)

The forum ‘OroPlatform’ is closed to new topics and replies.

Back to top