{"id":19005583,"url":"https://github.com/minhazulmin/laravel-multi-language","last_synced_at":"2026-05-15T21:38:30.656Z","repository":{"id":245160224,"uuid":"817407315","full_name":"Minhazulmin/Laravel-Multi-Language","owner":"Minhazulmin","description":" For Sponsor WhatsApp me +8801751337061. Laravel's localization features provide a convenient way to retrieve strings in various languages, allowing you to easily support multiple languages within your application.","archived":false,"fork":false,"pushed_at":"2024-06-21T17:47:38.000Z","size":367,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-21T14:19:14.161Z","etag":null,"topics":["language-switching-in-laravel","laravel","laravel-multi-language","localization","minhazulmin","multi-language","multi-languages"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Minhazulmin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["minhazulmin"]}},"created_at":"2024-06-19T16:32:25.000Z","updated_at":"2024-06-21T17:47:41.000Z","dependencies_parsed_at":"2024-06-20T06:41:51.503Z","dependency_job_id":"ba7cba31-fc1d-4324-97bd-9755af27a315","html_url":"https://github.com/Minhazulmin/Laravel-Multi-Language","commit_stats":null,"previous_names":["minhazulmin/laravel-multi-languages"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Minhazulmin/Laravel-Multi-Language","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Minhazulmin%2FLaravel-Multi-Language","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Minhazulmin%2FLaravel-Multi-Language/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Minhazulmin%2FLaravel-Multi-Language/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Minhazulmin%2FLaravel-Multi-Language/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Minhazulmin","download_url":"https://codeload.github.com/Minhazulmin/Laravel-Multi-Language/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Minhazulmin%2FLaravel-Multi-Language/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265703640,"owners_count":23814044,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["language-switching-in-laravel","laravel","laravel-multi-language","localization","minhazulmin","multi-language","multi-languages"],"created_at":"2024-11-08T18:28:29.848Z","updated_at":"2026-05-15T21:38:30.615Z","avatar_url":"https://github.com/Minhazulmin.png","language":"PHP","funding_links":["https://github.com/sponsors/minhazulmin"],"categories":[],"sub_categories":[],"readme":"# Laravel-Multi-Language\nLaravel's localization features provide a convenient way to retrieve strings in various languages, allowing you to easily support multiple languages within your application.\n\n![Sponsor](https://i.postimg.cc/QdPWVf9Y/Screenshot-1.png) \u003c/br\u003e \n**For Sponsor WhatsApp me +8801751337061**\u003c/br\u003e\nWatch video on YouTube: https://www.youtube.com/minit61 \u003c/br\u003e\nWatch video on Facebook: https://www.facebook.com/minit61\u003c/br\u003e\n\n## Output\n![App Screenshot](https://i.postimg.cc/pX9Zkc1X/Screenshot-1.png)\n\n\n## Installation\n\n**[Step - 1]** **Create new Project:**\u003cbr/\u003e\n(Open PowerShell In Your Local Machine and put this command)\n ```bash\nLaravel new laravel-multi-languages\n```\n**[Step - 2]** **Remove unnecessary code from welcome.blade.php, After that copy and past code into this file:**\n```bash\n \n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"{{ str_replace('_', '-', app()-\u003egetLocale()) }}\"\u003e\n\n\u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"\u003e\n\n    \u003ctitle\u003eLaravel\u003c/title\u003e\n    \u003clink href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css\" rel=\"stylesheet\"\n        integrity=\"sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH\" crossorigin=\"anonymous\"\u003e\n\u003c/head\u003e\n\n\u003cbody\u003e\n    \u003cmain class=\"\"\u003e\n        \u003cdiv class=\"border-bottom\"\u003e\n\n        \n        \u003cdiv class=\"container\"\u003e\n            \u003cheader class=\"d-flex flex-wrap align-items-center justify-content-center justify-content-md-between py-3\"\u003e\n      \u003cdiv class=\"col-md-3 mb-2 mb-md-0\"\u003e\n        \u003ca href=\"/\" class=\"d-inline-flex link-body-emphasis text-decoration-none\"\u003e\n          \u003csvg xmlns=\"http://www.w3.org/2000/svg\" width=\"40\" height=\"32\" class=\"d-block my-1\" viewBox=\"0 0 118 94\" role=\"img\"\u003e\u003ctitle\u003eBootstrap\u003c/title\u003e\u003cpath fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M24.509 0c-6.733 0-11.715 5.893-11.492 12.284.214 6.14-.064 14.092-2.066 20.577C8.943 39.365 5.547 43.485 0 44.014v5.972c5.547.529 8.943 4.649 10.951 11.153 2.002 6.485 2.28 14.437 2.066 20.577C12.794 88.106 17.776 94 24.51 94H93.5c6.733 0 11.714-5.893 11.491-12.284-.214-6.14.064-14.092 2.066-20.577 2.009-6.504 5.396-10.624 10.943-11.153v-5.972c-5.547-.529-8.934-4.649-10.943-11.153-2.002-6.484-2.28-14.437-2.066-20.577C105.214 5.894 100.233 0 93.5 0H24.508zM80 57.863C80 66.663 73.436 72 62.543 72H44a2 2 0 01-2-2V24a2 2 0 012-2h18.437c9.083 0 15.044 4.92 15.044 12.474 0 5.302-4.01 10.049-9.119 10.88v.277C75.317 46.394 80 51.21 80 57.863zM60.521 28.34H49.948v14.934h8.905c6.884 0 10.68-2.772 10.68-7.727 0-4.643-3.264-7.207-9.012-7.207zM49.948 49.2v16.458H60.91c7.167 0 10.964-2.876 10.964-8.281 0-5.406-3.903-8.178-11.425-8.178H49.948z\" fill=\"currentColor\"\u003e\u003c/path\u003e\u003c/svg\u003e\n        \u003c/a\u003e\n      \u003c/div\u003e\n\n      \u003cul class=\"nav col-12 col-md-auto mb-2 justify-content-center mb-md-0\"\u003e\n        \u003cli\u003e\u003ca href=\"#\" class=\"nav-link px-2 link-secondary\"\u003eHome\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#\" class=\"nav-link px-2\"\u003eFeatures\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#\" class=\"nav-link px-2\"\u003ePricing\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#\" class=\"nav-link px-2\"\u003eFAQs\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#\" class=\"nav-link px-2\"\u003eAbout\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n\n      \u003cdiv class=\"col-md-3 text-end\"\u003e\n        \u003cbutton type=\"button\" class=\"btn btn-outline-primary me-2\"\u003eLogin\u003c/button\u003e\n        \u003cbutton type=\"button\" class=\"btn btn-primary\"\u003eSign-up\u003c/button\u003e\n      \u003c/div\u003e\n      \u003cdiv class=\"col-md-1 text-end\"\u003e\n         \u003c!-- Languages ---\u003e\n        \u003cselect class=\"changeLang form-select\"\u003e\n            \u003coption value=\"en\" {{ session()-\u003eget('locale') == 'en' ? 'selected' : '' }}\u003e {{ __('home.English') }}\n            \u003c/option\u003e\n            \u003coption value=\"bn\" {{ session()-\u003eget('locale') == 'bn' ? 'selected' : '' }}\u003e {{ __('home.Bangla') }}\n            \u003c/option\u003e\n        \u003c/select\u003e\n      \u003c/div\u003e\n    \u003c/header\u003e\n        \u003c/div\u003e\n        \u003c/div\u003e\n    \u003c/main\u003e\n  \n\n    \u003cdiv style=\"margin-top: 16%; margin-left: 40%; font-size: x-large;\"\u003e\n        {{ __('home.title') }}\n    \u003c/div\u003e\n    \u003cscript src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js\"\n        integrity=\"sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz\" crossorigin=\"anonymous\"\u003e\n    \u003c/script\u003e\n    \u003cscript type=\"text/javascript\"\u003e\n        var url = \"{{ route('change_lang') }}\";\n        document.querySelectorAll(\".changeLang\").forEach(function(element) {\n            element.addEventListener('change', function() {\n                window.location.href = url + \"?lang=\" + this.value;\n            });\n        });\n    \u003c/script\u003e\n\u003c/body\u003e\n\n\u003c/html\u003e\n\n\n\n\n```\n\n**[Step - 3]** **create a folder on root directory (lang):** \u003c/br\u003e Then Create two folder **en** and **bn** After that make a file **home.php** ( See the folder structure in below ) \n```bash\n   lang/en/home.php\n   lang/bn/home.php\n```\n**[Step - 4]** **Copy and past into file**\u003c/br\u003e\n\n\n**lang/en/home.php**\n```bash\n  \u003c?php\n    return [\n      'title'   =\u003e 'I love coding',\n      'English' =\u003e 'English',\n      'Bangla'  =\u003e 'Bangla',\n    ];\n  ?\u003e\n```\n\n**lang/bn/home.php**\n```bash\n\u003c?php\n  return [\n      'title'   =\u003e 'আমি কোডিং ভালোবাসি',\n      'English' =\u003e 'ইংরেজি',\n      'Bangla'  =\u003e 'বাংলা',\n    ];\n?\u003e\n```\n**[Step - 5]** **Make a Route on the web.php:** \n```bash\n   use App\\Http\\Controllers\\LangController;\n\n   Route::get( 'lang/change', [LangController::class, 'change'] )-\u003ename( 'change_lang' );\n\n\n```\n**[Step - 6]** **Make a controller:** \n```bash\n php artisan make:controller LangController \n```\n\n**Copy and post on the controller**\n```bash\n\u003c?php\n\nnamespace App\\Http\\Controllers;\n\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Facades\\App;\n\nclass LangController extends Controller {\n    /**\n     * Change language\n     *\n     */\n    public function change( Request $request ) {\n        App::setLocale( $request-\u003elang );\n        session()-\u003eput( 'locale', $request-\u003elang );\n\n        return redirect()-\u003eback();\n    }\n}\n```\n**[Step - 7]** **Make a Middleware:** \n```bash\n\n php artisan make:middleware LanguageManager \n\n```\n**[Step - 8]** **Copy and past on the middleware**\n```bash\n\u003c?php\n\nnamespace App\\Http\\Middleware;\n\nuse Closure;\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Support\\Facades\\App;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\nclass LanguageManager {\n    /**\n     * Handle an incoming request.\n     *\n     * @param  \\Closure(\\Illuminate\\Http\\Request): (\\Symfony\\Component\\HttpFoundation\\Response)  $next\n     */\n    public function handle( Request $request, Closure $next ): Response {\n        if ( session()-\u003ehas( 'locale' ) ) {\n            App::setLocale( session()-\u003eget( 'locale' ) );\n        }\n\n        return $next( $request );\n    }\n}\n\n```\n**[Step - 9]** **Then register middleware on the bootstrap/app.php, Inside the withMiddleware; Look like this** \n```bash\n    -\u003ewithMiddleware( function ( Middleware $middleware ) {\n        $middleware-\u003eweb( append: [\n            \\App\\Http\\Middleware\\LanguageManager::class,\n        ] );\n    } )\n```\n**[Step - 10]** **run the command on the project terminal** \n```bash\n \tphp artisan serve\n```\nHit the url\n```bash\n\thttp://127.0.0.1:8000/\n```\n## Authors\n\n- [@minhazulmin](https://www.github.com/minhazulmin)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminhazulmin%2Flaravel-multi-language","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminhazulmin%2Flaravel-multi-language","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminhazulmin%2Flaravel-multi-language/lists"}