Search code examples
laravellaravel-5localizationlaravel-bladelang

Laravel: Whole lang files in on view


I want to localize my Laravel app.

I call it on blade like this: @lang('bot.bots')

But my view I got this: enter image description here

My bot.php is:

<?

return [

    'bots' => 'Bot|Bots',
    'addBot' => 'Add bot',
    'editBot' => 'Edit bot',
    'deleteBot' => 'Delete bot',
    'compose' => 'Compose',
    'addGroup' => 'Add group',
    'editGroup' => 'Edit group',
    'deleteGroup' => 'Delete group',
    'confirmDeleteGroup' => 'Are you sure you want to delete the group?',
    'textRecognition' => 'Text recognition',
    'newRule' => 'Add rule',
    'deleteRule' => 'Delete rule',
    'confirmDeleteRule' => 'Are you sure you want to delete the rule?',
    'editBot' => 'Bot szerkesztése',
    'input' => 'Input',
    'output' => 'Output',
    'addInput' => 'Add input',
    'addOutput' => 'Add output',
    'blocks' => 'Block|Blocks',
    'groups' => 'Group|Groups',
    'text' => 'Text',
    'broadcast' => 'Broadcast',
    'analytics' => 'Analytics',
    'chatPartners' => 'Chat Partners',
];

What can be the problem? I did everything like what's in the documentation


Solution

  • Just indicate the count like this

    $bots_count = 4 //replace with count
    @lang('bot.bots', $bots_count)
    

    You may also use translation choices, for which your array would look like this

    return [
    
        'bots' => '{0} No Bots|{1} Bot|[2,*] Bots',
        ...
    ];