{"id":13545636,"url":"https://github.com/akaunting/laravel-language","last_synced_at":"2025-04-02T15:31:39.368Z","repository":{"id":37425038,"uuid":"102290249","full_name":"akaunting/laravel-language","owner":"akaunting","description":"Language switcher package for Laravel","archived":false,"fork":false,"pushed_at":"2023-01-27T14:58:50.000Z","size":140,"stargazers_count":221,"open_issues_count":6,"forks_count":48,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-25T06:53:16.827Z","etag":null,"topics":["akaunting","language","laravel","locale","php","switcher"],"latest_commit_sha":null,"homepage":"https://akaunting.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/akaunting.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-03T19:52:45.000Z","updated_at":"2025-02-02T14:14:40.000Z","dependencies_parsed_at":"2023-02-15T10:16:35.376Z","dependency_job_id":null,"html_url":"https://github.com/akaunting/laravel-language","commit_stats":null,"previous_names":["akaunting/language"],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akaunting%2Flaravel-language","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akaunting%2Flaravel-language/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akaunting%2Flaravel-language/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akaunting%2Flaravel-language/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akaunting","download_url":"https://codeload.github.com/akaunting/laravel-language/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246841822,"owners_count":20842654,"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":["akaunting","language","laravel","locale","php","switcher"],"created_at":"2024-08-01T11:01:07.720Z","updated_at":"2025-04-02T15:31:34.360Z","avatar_url":"https://github.com/akaunting.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Language switcher package for Laravel\n\n![Downloads](https://img.shields.io/packagist/dt/akaunting/laravel-language)\n[![StyleCI](https://github.styleci.io/repos/102290249/shield?style=flat\u0026branch=master)](https://styleci.io/repos/102290249)\n[![Quality](https://img.shields.io/scrutinizer/quality/g/akaunting/laravel-language?label=quality)](https://scrutinizer-ci.com/g/akaunting/laravel-language)\n[![License](https://img.shields.io/github/license/akaunting/laravel-language)](LICENSE.md)\n\nThis package allows switching locale easily on Laravel projects. It's so simple to use, once it's installed, your App locale will change only by passing routes into SetLanguage middleware.\n\n**Top features:**\n\n- Change automatically app locale depending on user browser configuration\n- Language flags built-in for easy implementation\n- Get language name like 'English' or 'Español' from codes such as 'en' or 'es'\n- Option to choose short (en) or long (en-GB) language code\n- Store locale on users table\n- Restrict users to set languages you don't have translations\n- Helper functions for clean, simple and easy to read API\n- Supports Carbon and Date packages\n\n## Getting Started\n\n### 1. Install\n\nRun the following command:\n\n```\ncomposer require akaunting/laravel-language\n```\n\n### 2. Register (for Laravel \u003c 5.5)\n\nRegister the service provider in ``config/app.php``\n\n```php\nAkaunting\\Language\\Provider::class,\n```\n\nAdd alias if you want to use the facade.\n\n```php\n'Language'   =\u003e Akaunting\\Language\\Facade::class,\n```\n\n### 3. Publish\n\nPublish config, migration and blade files.\n\n```\nphp artisan vendor:publish --tag=language\n```\n\n### 4. Migrate\n\n\nAdd locale column to users table:\n\n```\nphp artisan migrate\n```\n\n\n### 5. Configure\n\nDefault values can be modified also on `config/language.php`\n\n#### Keys\n\n- route: Makes route available\n- carbon: Sets briannesbitt/carbon translator language\n- date: Sets jenssegers/date translator language\n- home: Make home route available\n- auto: Sets language automatically depending on user's browser config\n- prefix: Prefix of routes URI to set locale\n- middleware: default middleware to set locale\n- controller: default controller to handle locale\n- flags: Settings such as width, class etc for flags\n- mode: The language code and name mode\n- allowed: Allowed language codes\n- all: Available language names and codes\n\n## Usage\n\n### Middleware\n\nAll routes in which you want to set language should be under the `language`\nmiddleware to set at each request to App locale.\n\n```php\nRoute::group(['middleware' =\u003e 'language'], function () {\n\n    // Here your routes\n\n});\n```\n\n### URL\n\n- Via URL with return home: /languages/{locale}/home\n- Via URL with return back: /languages/{locale}/back\n\n**Tip:** */languages prefix can be changed from ```config/language.php```*\n\n## Methods\n\n### language()-\u003eallowed()\n\nReturns an array with ```[$code =\u003e $name]``` for all allowed\nlanguages of config. Example usage on blade:\n\n```php\n@foreach (language()-\u003eallowed() as $code =\u003e $name)\n    \u003ca href=\"{{ language()-\u003eback($code) }}\"\u003e{{ $name }}\u003c/a\u003e\n@endforeach\n```\n\n### language()-\u003eflags()\n\nReturns an output with flags for all allowed languages of config.\nOutput can be changed from ```resources/views/vendor/language``` folder\n\n### language()-\u003eflag()\n\nReturns the flag of the current locale.\nOutput can be changed from ```resources/views/vendor/language``` folder\n\n### language()-\u003enames($codes = null)\n\nGet an array like ```[$code =\u003e $name]``` from an array of only $codes.\n\n\n### language()-\u003ecodes($langs = null)\n\nGet an array like ```[$name =\u003e $code]``` from an array of only $langs.\n\n### language()-\u003eback($code)\n\nReturns the URL to set up language and return back: ```back()```\n\nAlso if you prefer to use directly route() function you can use it\nas following code:\n\n```php\n{{ route('language::back', ['locale' =\u003e $code]) }}\n```\n\n### language()-\u003ehome($code)\n\nReturns the URL to set language and return to home: ```url('/')```\n\nAlso if you prefer to use directly route() function you can use it\nas following code:\n\n```php\n{{ route('language::home', ['locale' =\u003e $code]) }}\n```\n\n### language()-\u003egetName($code = 'default')\n\nReturns the language name of ```$code``` if specified or the current\nlanguage set if not.\n\n**Tip:** *Use app()-\u003egetLocale() to get the current locale*\n\n### language()-\u003egetCode($name = 'default')\n\nReturns the language code of ```$name``` if specified or the current\nlanguage set if not.\n\n## Changelog\n\nPlease see [Releases](../../releases) for more information what has changed recently.\n\n## Contributing\n\nPull requests are more than welcome. You must follow the PSR coding standards.\n\n## Security\n\nIf you discover any security related issues, please email security@akaunting.com instead of using the issue tracker.\n\n## Credits\n\n- [Denis Duliçi](https://github.com/denisdulici)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakaunting%2Flaravel-language","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakaunting%2Flaravel-language","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakaunting%2Flaravel-language/lists"}