{"id":35495580,"url":"https://github.com/bpnpdl1/easy-locale","last_synced_at":"2026-01-13T23:01:03.065Z","repository":{"id":331362459,"uuid":"1126322948","full_name":"bpnpdl1/easy-locale","owner":"bpnpdl1","description":"Easy Locale is a lightweight Laravel package that makes URLs locale-aware without boilerplate. The default locale uses clean, unprefixed URLs, while non‑default locales are automatically prefixed.","archived":false,"fork":false,"pushed_at":"2026-01-03T17:24:01.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-07T00:21:39.326Z","etag":null,"topics":["laravel-package","localization","url"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/bpnpdl/easy-locale","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bpnpdl1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-01T16:55:41.000Z","updated_at":"2026-01-04T10:20:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bpnpdl1/easy-locale","commit_stats":null,"previous_names":["bpnpdl1/easy-locale"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/bpnpdl1/easy-locale","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpnpdl1%2Feasy-locale","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpnpdl1%2Feasy-locale/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpnpdl1%2Feasy-locale/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpnpdl1%2Feasy-locale/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bpnpdl1","download_url":"https://codeload.github.com/bpnpdl1/easy-locale/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bpnpdl1%2Feasy-locale/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28399505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["laravel-package","localization","url"],"created_at":"2026-01-03T17:14:18.749Z","updated_at":"2026-01-13T23:01:03.046Z","avatar_url":"https://github.com/bpnpdl1.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Easy Locale for Laravel\n\nEasy Locale adds locale-aware routing and link generation to Laravel with a simple, predictable rule:\n\n- The default locale has no URL prefix (clean URLs).\n- Non-default locales are prefixed as the first URL segment (e.g., `/np/about`).\n\nThis helps you ship a single set of routes while presenting localized URLs only when needed.\n\n## Features\n\n- Clean URLs for your default locale (e.g., `en` → `/about`).\n- Prefixed URLs for non-default locales (e.g., `np` → `/np/about`).\n- Lightweight helper to group your routes once and let the package handle locale prefixes.\n- Built-in locale switch endpoint to redirect correctly when changing languages.\n- Optional, publishable Blade switcher UI and translation stubs.\n\n## Requirements\n\n- PHP 8.2+\n- Laravel 12 (Illuminate Support ^12.0)\n\n## Installation (Composer)\n\nInstall from Packagist:\n\n```bash\ncomposer require bpnpdl/easy-locale\n```\n\nLaravel will auto-discover the service provider.\n\n## Publish assets\n\n```bash\nphp artisan vendor:publish --provider=\"Bpnpdl\\EasyLocale\\EasyLocaleServiceProvider\" --tag=config\nphp artisan vendor:publish --provider=\"Bpnpdl\\EasyLocale\\EasyLocaleServiceProvider\" --tag=lang\nphp artisan vendor:publish --provider=\"Bpnpdl\\EasyLocale\\EasyLocaleServiceProvider\" --tag=views\n```\n\n## Configuration\n\n`config/easy-locale.php`:\n\n```php\nreturn [\n        'locales' =\u003e [\n                'en' =\u003e 'English',\n                'np' =\u003e 'नेपाली',\n                // add more like:\n                // 'hi' =\u003e 'Hindi',\n                // 'es' =\u003e 'Español',\n        ],\n        'default' =\u003e 'en', // default app locale; has no URL prefix\n];\n```\n\n## Routing: group by current locale\n\nGroup your frontend routes once. Easy Locale mounts them with no prefix for the default locale and with `/{locale}` for others:\n\n```php\nuse Bpnpdl\\EasyLocale\\Services\\GroupLocaleRouteService;\n\n$frontend = function () {\n        Route::get('/', fn () =\u003e view('welcome'))-\u003ename('home');\n        Route::get('/about', [PageController::class, 'about'])-\u003ename('about');\n        Route::get('/contact', [PageController::class, 'contact'])-\u003ename('contact');\n};\n\nGroupLocaleRouteService::setLocaleRoutePrefix($frontend);\n```\n\nBehind the scenes, the package sets `app()-\u003egetLocale()` from the first URL segment if it matches a configured locale; otherwise it uses your configured default.\nThis means you avoid duplicating route definitions while still serving localized paths.\n\n## Locale switching\n\nThe package registers:\n\n- `GET /locale/{locale}` → `easy-locale.switch-language`\n\nUse it to switch languages without breaking URLs. Examples:\n\n```blade\n\u003ca href=\"{{ route('easy-locale.switch-language', 'en') }}\"\u003eEnglish\u003c/a\u003e\n\u003ca href=\"{{ route('easy-locale.switch-language', 'np') }}\"\u003eनेपाली\u003c/a\u003e\n```\n\nIf you prefer a ready-made UI, include the switcher view:\n\n```blade\n@include('easy-locale::switcher')\n{{-- or if you published views: --}}\n@include('vendor.easy-locale.switcher')\n```\n\n## Translations and views\n\n- Translations can be published to `lang/vendor/easy-locale`.\n- Views can be published to `resources/views/vendor/easy-locale`.\n\nUse your own app translation files (e.g., `lang/en/pages.php`, `lang/np/pages.php`) for labels and navigation. The package does not override your app’s translation loading; it focuses on routing and URL shape.\n\nIn your app views you can use normal Laravel translation files (e.g., `lang/en/*.php`, `lang/np/*.php`). The package itself does not override your app’s translation loading.\n\n## Example: links\n\nWhen you build links using named routes, the current locale determines the URL. Use your app's translation labels for link text:\n\n```blade\n\u003ca href=\"{{ route('home') }}\"\u003e{{ __('pages.home') }}\u003c/a\u003e\n\u003ca href=\"{{ route('about') }}\"\u003e{{ __('pages.about') }}\u003c/a\u003e\n\u003ca href=\"{{ route('contact') }}\"\u003e{{ __('pages.contact') }}\u003c/a\u003e\n```\n\n- Default locale `en`: `/`, `/about`, `/contact`\n- Locale `np`: `/np`, `/np/about`, `/np/contact`\n\n## Troubleshooting\n\n- Seeing `/en/...` when you expect no prefix? Ensure `default` in `config/easy-locale.php` is set to `en` and that you group routes with `GroupLocaleRouteService`.\n- Switching to the default locale still shows a prefix? Use the `easy-locale.switch-language` route; it removes the prefix for the default locale.\n- Added a new locale but URLs don’t work? Add the locale code to `config('easy-locale.locales')`, clear caches, and verify your route group is using `GroupLocaleRouteService`.\n\n## Contributing\n\nWe welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for the full development workflow, coding standards, and PR process.\n\n## License\n\nMIT — see [LICENSE.md](LICENSE.md).\n\n## Contact\n\n- Email: bipinpaudel6774@gmail.com\n- LinkedIn: https://www.linkedin.com/in/bpnpdl/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpnpdl1%2Feasy-locale","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbpnpdl1%2Feasy-locale","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbpnpdl1%2Feasy-locale/lists"}