{"id":34007699,"url":"https://github.com/lase-peco/localization","last_synced_at":"2026-04-07T17:31:57.176Z","repository":{"id":41200376,"uuid":"352977667","full_name":"lase-peco/localization","owner":"lase-peco","description":"A simple localization library for Laravel","archived":false,"fork":false,"pushed_at":"2024-12-15T16:22:32.000Z","size":212,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-14T22:57:41.922Z","etag":null,"topics":["flags","internationalization","language","laravel","localization","php"],"latest_commit_sha":null,"homepage":"https://lase-peco.com","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/lase-peco.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}},"created_at":"2021-03-30T11:32:21.000Z","updated_at":"2024-12-15T16:21:00.000Z","dependencies_parsed_at":"2022-09-12T14:32:30.704Z","dependency_job_id":null,"html_url":"https://github.com/lase-peco/localization","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/lase-peco/localization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lase-peco%2Flocalization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lase-peco%2Flocalization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lase-peco%2Flocalization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lase-peco%2Flocalization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lase-peco","download_url":"https://codeload.github.com/lase-peco/localization/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lase-peco%2Flocalization/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31522268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"ssl_error","status_checked_at":"2026-04-07T16:28:06.951Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["flags","internationalization","language","laravel","localization","php"],"created_at":"2025-12-13T11:09:46.912Z","updated_at":"2026-04-07T17:31:57.159Z","avatar_url":"https://github.com/lase-peco.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A simple localization library\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/lase-peco/localization.svg?style=flat-square)](https://packagist.org/packages/lase-peco/localization)\n[![Total Downloads](https://img.shields.io/packagist/dt/lase-peco/localization.svg?style=flat-square)](https://packagist.org/packages/lase-peco/localization)\n\n[comment]: \u003c\u003e ([![Build Status]\u0026#40;https://img.shields.io/travis/lase-peco/localization/master.svg?style=flat-square\u0026#41;]\u0026#40;https://travis-ci.org/lase-peco/localization\u0026#41;)\n[comment]: \u003c\u003e ([![Quality Score]\u0026#40;https://img.shields.io/scrutinizer/g/lase-peco/localization.svg?style=flat-square\u0026#41;]\u0026#40;https://scrutinizer-ci.com/g/lase-peco/localization\u0026#41;)\n\nA simple localization library.\n\n## Notes\n\nThis whole package is hugely inspired by [mcamara/laravel-localization](https://github.com/mcamara/laravel-localization), we wanted something simpler, with support for PHP IntlDateFormatter, so we made our package.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require lase-peco/localization\n```\n\nThen in your Web kernel file `app/Http/Kernel.php` in the `web` array in `$middlewareGroups`, add this line to the end of the array:\n\n```php\n'web' =\u003e [\n     // Other middlewares\n     //\n     \\LasePeco\\Localization\\Http\\Middleware\\Localization::class,\n],\n```\n\nThen publish the config file `localization.php` with the following command to define your application languages:\n\n``` php\nphp artisan  vendor:publish --provider=\"LasePeco\\Localization\\LocalizationServiceProvider\"\n```\n\n## Usage\n\n### Get current language\n\nReturn a string with the current language `\"en\"`.\n\n``` php\nLocalization::getCurrentLocale() \n``` \n\n### Get current language name\n\nReturn a string with the name of the current language `\"English\"`.\n\n``` php\nLocalization::getCurrentLocaleName() \n``` \n### Get current language native name\n\nReturn a string with the native name of the current language `\"Deutsch\"`.\n\n``` php\nLocalization::getCurrentLocaleNativeName() \n```\n### Get current regional language \n\nReturn a string with the current regional language `\"en_GB\"`.\n\n``` php\nLocalization::getCurrentLocaleRegional()\n``` \n\n### Get keys of supported languages\n\nReturn an array of supported languages in your application:\n\n\n``` php\nLocalization::getSupportedLanguagesKeys() \n```\n\n``` php\n//return\n[\n  0 =\u003e \"ar\"\n  1 =\u003e \"en\"\n  2 =\u003e \"de\"\n]\n```\n### Get supported languages\n\nReturn an associative array with the supported languages for your application:\n\n\n\n``` php\nLocalization::getSupportedLocales()\n```\n``` php\n//return\n[\n  \"en\" =\u003e [\n    \"direction\" =\u003e \"ltr\"\n    \"regional\" =\u003e \"en_GB\"\n    \"name\" =\u003e \"English\"\n    \"native\" =\u003e \"English\"\n  ]\n  \"de\" =\u003e [\n    \"direction\" =\u003e \"ltr\"\n    \"regional\" =\u003e \"de_DE\"\n    \"name\" =\u003e \"German\"\n    \"native\" =\u003e \"Deutsch\"\n  ]\n]\n```\n\n### Set application language\n\nTo set the language of your application use the provided route `'locale'` with the selected language as a parameter:\n\n``` php\nroute('locale', [$key]) // $key = \"en\" or \"de\" or ...\n```\n\nOr make a get request to `/local/{$local}`, this will set the application language to the selected language.\n\n### Time format\n\n`Localization::formatDate($date)` return a string of the date formatted in native Language:\n\nExample\n\n``` php\n$model-\u003ecreated_at-\u003eintlDateFormat();\n// or\nLocalization::formatDate($model-\u003ecreated_at);\n```\n``` php\n//return\n'Sep 14, 2021'   // 'en' \n'14.09.2021'     // 'de'\n'14 sept. 2021'  // 'fn'\n'١٤‏/٠٩‏/٢٠٢١'    // 'ar'\n```\n### Date format\n`Localization::formatTime($time)` return a string of the time formatted in native Language:\n\nExample\n\n``` php\n$model-\u003ecreated_at-\u003eintlTimeFormat();\n// or\nLocalization::formatTime($model-\u003ecreated_at);\n```\n``` php\n//return\n'1:27 PM'  // 'en' \n'13:27'    // 'de'\n'١:٢٧ م'   // 'ar'\n```\n### Date-Time format\n`Localization::formatDateTime($date_time)` return a string of the date and time formatted in native Language:\n\nExample\n\n``` php\n$model-\u003ecreated_at-\u003eintlDateTimeFormat();\n// or\nLocalization::formatDateTime($model-\u003ecreated_at);\n```\n``` php\n// return\n'Sep 14, 2021, 1:27 PM'  // 'en' \n'14.09.2021, 13:27'      // 'de'\n'14 sept. 2021, 13:27'   // 'fr'\n'١٤‏/٠٩‏/٢٠٢١, ١:٢٧ م'    // 'ar'\n```\n\n### Flags\n\n`Localization::getCurrentLocaleFlag()` return html string that represents the svg flag.\n`Localization::getSupportedLocalesFlags()` return an array, each item contains a html string that represents the svg flag.\n\nThe flags are set to take the full height and width of their parent tag.\n\nExample using tailwindcss!\n\n``` html\n\u003cdiv class=\"inline-block h-4 w-auto mr-2\"\u003e{!! Localization::getCurrentLocaleFlag() !!}\u003c/div\u003e{{Localization::getCurrentLocaleNativeName()}}\n```\n``` html\n@foreach(Localization::getSupportedLocales() as $key =\u003e $locale)\n    \u003ca href=\"{{ route('locale', [$key]) }}\"\n       class=\"block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100\"\n       role=\"menuitem\"\u003e\u003cspan class=\"flex items-center\"\u003e\u003cspan class=\"inline-block h-4 w-auto mr-2\"\u003e{!! Localization::getSupportedLocalesFlags()[$key] !!}\u003c/span\u003e{{$locale['native']}}\u003c/span\u003e\u003c/a\u003e\n@endforeach\n```\n\n\n### Testing\n\n``` bash\ncomposer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email a.dabak@lase-peco.com instead of using the issue tracker.\n\n## Credits\n\n- [Ahmed Dabak](https://github.com/lase-peco)\n- [Abdulsalam Emesh](https://github.com/lase-peco)\n- [All Contributors](CONTRIBUTING.md)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flase-peco%2Flocalization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flase-peco%2Flocalization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flase-peco%2Flocalization/lists"}