Search code examples
phplaravellaravel-bladelang

Laravel, @lang and strtolower()


I'm trying to convert a string to lowercase like this:

@lang(strtolower('header.home'))

This not working. Any Idea? Thx.


Solution

  • try this :

    {{ strtolower(__('header.home')) }}
    

    for more info :

    You may retrieve lines from language files using the __ helper function. The __ method accepts the file and key of the translation string as its first argument. For example, let's retrieve the welcome translation string from the resources/lang/messages.php language file:

    echo __('messages.welcome');
    
    echo __('I love programming.');
    

    Of course if you are using the Blade templating engine, you may use the {{ }} syntax to echo the translation string or use the @lang directive:

    {{ __('messages.welcome') }}
    
    @lang('messages.welcome')
    

    If the specified translation string does not exist, the __ function will simply return the translation string key. So, using the example above, the __ function would return messages.welcome if the translation string does not exist.