OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform Translate address type

This topic contains 12 replies, has 2 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
  • #37120

    William Radi
    Participant

    Hi!
    When creating a new contact (/contact/create), and adding a new address, there is a type checkbox, and there are two options: Billin and Shipping:

    Adding a new address at /contact/create

    And this appear too at the view page (/contact/view/), inside the address box:

    Billing and Shipping at contact view (/contact/view)

    So, how do I translate this options?

    Based on this file:

    entities.en.yml

    I tryed to add the file entities.pt_BR.yml inside the translation folder, but it didn’t work. My entities.pt_BR.yml file looks like this:

Viewing 12 replies - 1 through 12 (of 12 total)
  • Author
    Replies
  • #37121

    William Radi
    Participant

    Hi!
    I forgot to say… I’d like to do it programmatically.

    Thanks!

    #37122

    William Radi
    Participant

    If necessary, link from the first image:
    https://pasteboard.co/HfP6EFv.png

    from the second image:
    https://pasteboard.co/HfP76vKV.png

    #37123

    Andrey Yatsenko
    Moderator

    Hi William,
    You are on the right way, after adding translation please run the command app/console oro:translation:load --env=prod

    #37124

    William Radi
    Participant

    Hello Anyt!

    Thanks for the answer! I didn’t know about this command… It found some other translation files, but in this case, “Billing” and “Shipping” still there… =/

    #37125

    Andrey Yatsenko
    Moderator

    Sorry misleading you, AddressType is non a standard choice, it’s a Gedmo Translatable Entity.

    So from the code side you can add translations using data migrations.

    You can check the default migration that loads the original entities, at line 50 it just adds same translations for all the enabled languages.
    https://github.com/oroinc/platform/blob/2.6.1/src/Oro/Bundle/AddressBundle/Migrations/Data/ORM/LoadAddressTypeData.php#L50

    So you probably should create one more migration that will fetch this entities by title or id and add required translations for your locale like in above example.

    #37126

    William Radi
    Participant

    Anyt, sorry by late..

    I’m new developping with Oro.. Could you give me more detales? :D
    I was trying to do what you said, but unsuccessfully…

    I need to create another Migration that fetch the entityes… Is it like the beggining of the code that you sended, but using new entities with portuguese names?

    turn into:

    And do I need to use a data fixture to populate the table oro_address_type_translation?

    Or also… If it’s nothing to do.. which files Do I need to create? rsrs

    Thanks a lot, man!

    #37127

    William Radi
    Participant

    Another question, less long-winded.. rs
    (’cause I’m still trying.. hehe)

    Do I need to update the oro_address_type table or oro_address_type_translation table?

    Thanks again!

    #37128

    Andrey Yatsenko
    Moderator

    Migration just a way to update database state from the code so you don’t need to edit it manually after running migration.

    At the example above we just added some data, and you need to update it, so instead of creating new content you need just to fetch it from the database with doctrine, I guess you are familiar with it, like $em->find(AddressType::class, $entityId)
    And after fetching just add new translation like it’s added at the above example.

    After the migration will be ready make a backup of the database state, just in case something will go wrong and run from the cli command app/console oro:migration:data:load --bundles=YourFancyBundle
    This will synchronise your code and the database so you will get translations loaded to the database.

    #37129

    William Radi
    Participant

    Hi, Andrey! Thanks for the answer!
    But I think I need more details … because it’s not working and I’m sure it’s my fault ..

    Could you explain it to me again? Because more problems about entity translation are coming up …

    So, I need to create a Data Fixture, like the file here
    https://github.com/oroinc/platform/blob/2.6.1/src/Oro/Bundle/AddressBundle/Migrations/Data/ORM/LoadAddressTypeData.php#L50

    Where do I put it and how to set the $entityId?

    Thanks again!

    #37130

    Andrey Yatsenko
    Moderator

    You can find original entity not by id but by label as it’s unique, like
    $addressType = $em->getRepository(AddressType::class)->findByLabel('Billing');

    #37131

    William Radi
    Participant

    Hi, Andrey!!

    With your help and after some other researchs, I could translate! :D

    That is my data fixture code:

    Thanks a lot, man!

    #37132

    William Radi
    Participant

    I forgot to close the topic.. hehe

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

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

Back to top