About Translation and its variables



  • Right now I am translating Bagisto's front-end into Spanish language, and I found the word "Quantity" shown in the shopping cart, it was in hard code. The word is in the file:

    packages\Webkul\Shop\src\Resources\views\checkout\cart\mini-cart.blade.php
    

    In the following line 82 of code:

    <div class="item-qty">Quantity - {{ $item->quantity }}</div>
    

    To solve this, I replaced the word "Quantity" with the following:

    {{ __('shop::app.checkout.cart.quantity.quantity') }}
    

    Remaining line 82 of the code as follows:

    <div class="item-qty">{{ __('shop::app.checkout.cart.quantity.quantity') }} - {{ $item->quantity }}</div>
    

    In this way I have managed to take the translation corresponding to the Spanish language from "Quantity" to "Cantidad"

    Please change that line for future updates, if I find other lines of code the same I will report them here.

    Have a nice day!



  • @HombreGeek Thanks for your suggestion and cooperation.



  • @prateek-webkul Hello! I hope everythings is ok with you.

    Continuing the work with my spanish translation I've found another issue, that you should be considered.

    As an Admin trying to edit a customer, to change his o her status to active or inactive; This part shows a two a hard core words, "Actived" and "Blocked".

    This two words came from this file:

    packages\Webkul\Admin\src\DataGrids\CustomerDataGrid.php
    

    in the lines 82 and 85, as followings:

    'wrapper' => function ($row) {
       if ($row->status == 1) {
            return 'Activated';  // line 82 inm CustomerDataGrid.php
       } else {
            return 'Blocked';  // line 85 in CustomerDataGrid.php
       }
    }
    

    To be able to change this two word my spanish language, I did the following:

    'wrapper' => function ($row) {
       if ($row->status == 1) {
            return trans('admin::app.datagrid.active');  // line 82 replaced
       } else {
            return trans('admin::app.datagrid.inactive');  // line 85 in CustomerDataGrid.php
       }
    }
    

    Then I added these two properties - values pairs in the datagrid array, which is in my spanish translation file:

    packages\Webkul\Admin\src\Resources\lang\es\app.php
    
    'datagrid' => [
    .
    .
    .
    
    'active' => 'Activo',
    'inactive' => 'Inactivo',
    
    .
    .
    .
    ],
    

    Please consider it to future updates to make easier the translation to other language.

    Have nice day!


Log in to reply