laravel localization

623 0 0 0

Last Updated : 2024-04-19 22:33:38

this snippet wil teach you laravel localization

laravel localization makes it easy to set various languages files in resources/lang folder . with this directory there may be subfolders for each language supported by the application . 


you can add more files as you want , and in these files you provide general language lines for your project to use anywhere in your application . 


these file will return associative array .. don't forget that as the example below


<?php

return [

/*
|--------------------------------------------------------------------------
| General Language Lines
|--------------------------------------------------------------------------
|
|
*/

'federal' => 'Federal',
'bills' => 'Bills',
'debates' => 'Debates',
'mps' => 'MPs',
'committees' => 'Committees',
'votes' => 'Votes',

];

you can access any general lines of these files in blade files like this


{{__('header.bills')}}  // this will access bills name in the main array in resources/lang/header.php

OR USE THE ANOTHER METHOD

@lang('header.bills') // this will access bills name in the main array in resources/lang/header.php

Mahmoud Anwar

Mahmoud Anwar

Back End Developer with a passion for developing innovative web applications that expedite the efficiency and effectiveness of organizational success. Well-versed in technology and writing code to create systems that are reliable and user-friendly. Also has the proven ability to motivate, educate, and collaborate effectively to build web applications and effectively track changes. Confident communicator, strategic thinker, and innovative creator to develop software that is customized to meet a company’s organizational needs, highlight their core competencies, and further their success.