Translate value in the select box

  • Pippo Poppo
    Participant
      # 2 months, 4 weeks 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 months, 3 weeks 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

      • Pippo Poppo
        Participant
          # 2 months, 3 weeks ago

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

        • Pippo Poppo
          Participant
            # 2 months, 3 weeks ago

            Do you have an answer?

          • laravel-bap
            Keymaster
              # 2 months, 3 weeks 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.

            • Pippo Poppo
              Participant
                # 2 months, 3 weeks 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 months, 3 weeks ago

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

                  try this.

                • Pippo Poppo
                  Participant
                    # 2 months, 3 weeks ago

                    Thank you. It works properly

                  You must be logged in to reply to this topic.