Translate value in the select box

    • Danko
      Participant
        # 2 years, 6 months ago

        Hello,

        I need to translate values from a select box.
        In the Contacts module -> Settings -> I have to translate the name of the value of the select box “Status”.
        How can I do?
        Thanks

      • laravel-bap
        Keymaster
          # 2 years, 6 months ago

          if you need to translate to any other language just translate value in settings.

          if you need to have multiple translations i think you need to uses some additional library and integrate

          https://github.com/spatie/laravel-translatable

        • Danko
          Participant
            # 2 years, 6 months ago

            Sorry but I didn’t explain myself …
            I have to translate the values of the “Status” selectbox.

          • Danko
            Participant
              # 2 years, 5 months ago

              Do you have an answer?

            • laravel-bap
              Keymaster
                # 2 years, 5 months ago

                Hi, values of “select box” aka “dictionaries” are stored in database. And they don’t have translations. They are showed as they are.

                If you need to translate them to multiple languages you can add tranform to ContactForm field like that:

                But this is only for form.

                — to translate values on details edit
                Modules/Platform/Core/Resources/views/components/types/manyToOne.blade.php and add trans(‘contacts::contacts.dict.’.$item);

                later you will need to translate datatables and filters.

              • Danko
                Participant
                  # 2 years, 5 months ago

                  Hi, thanks …
                  I have tried and works in the form (selectbox value) but in the view it does not translate. Also how do I add the translation of other modules and not just the translation there ‘Contacts’?
                  Below the file Modules/Platform/Core/Resources/views/components/types/manyToOne.blade.php
                  Did I have something here?

                  @if($entity->$fieldName != null )
                  @if(isset($options[‘dont_translate’]))
                  {{
                  $entity->{$options[‘relation’]}->{$options[‘column’]}
                  }}
                  @else
                  {{
                  $entity->{$options[‘relation’]}->{$options[‘column’]}
                  }}
                  @endif
                  @endif
                  trans(‘contacts::contacts.dict.’.$item);

                • laravel-bap
                  Keymaster
                    # 2 years, 5 months ago

                    There was translations for dicts in one of the first version – but this was a dead end.

                    try this.

                  • Danko
                    Participant
                      # 2 years, 5 months ago

                      Thank you. It works properly

                  Viewing 7 reply threads

                  You must be logged in to reply to this topic.