{"id":16458164,"url":"https://github.com/akalongman/laravel-multilang","last_synced_at":"2025-04-10T05:06:34.201Z","repository":{"id":49096748,"uuid":"56454767","full_name":"akalongman/laravel-multilang","owner":"akalongman","description":"Package to integrate multi language (multi locale) functionality in Laravel 5.x.","archived":false,"fork":false,"pushed_at":"2024-08-02T10:22:34.000Z","size":513,"stargazers_count":55,"open_issues_count":7,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-10T05:06:20.156Z","etag":null,"topics":["laravel","laravel-package","localization","multilang","php"],"latest_commit_sha":null,"homepage":"","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/akalongman.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}},"created_at":"2016-04-17T19:38:41.000Z","updated_at":"2024-08-02T10:23:28.000Z","dependencies_parsed_at":"2024-06-18T22:46:29.146Z","dependency_job_id":"1d8142af-6f51-4752-9e7e-068075c36227","html_url":"https://github.com/akalongman/laravel-multilang","commit_stats":{"total_commits":174,"total_committers":9,"mean_commits":"19.333333333333332","dds":0.0977011494252874,"last_synced_commit":"5782afbbb97e285db639f456b5fce30417dde5cd"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akalongman%2Flaravel-multilang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akalongman%2Flaravel-multilang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akalongman%2Flaravel-multilang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akalongman%2Flaravel-multilang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akalongman","download_url":"https://codeload.github.com/akalongman/laravel-multilang/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161274,"owners_count":21057555,"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":["laravel","laravel-package","localization","multilang","php"],"created_at":"2024-10-11T10:44:26.725Z","updated_at":"2025-04-10T05:06:34.179Z","avatar_url":"https://github.com/akalongman.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel 5.x MultiLanguage\n\n[![Build Status](https://img.shields.io/travis/akalongman/laravel-multilang/master.svg?style=flat-square)](https://travis-ci.org/akalongman/laravel-multilang)\n[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/akalongman/laravel-multilang.svg?style=flat-square)](https://scrutinizer-ci.com/g/akalongman/laravel-multilang/?branch=master)\n[![Code Quality](https://img.shields.io/scrutinizer/g/akalongman/laravel-multilang.svg?style=flat-square)](https://scrutinizer-ci.com/g/akalongman/laravel-multilang/?branch=master)\n[![Latest Stable Version](https://img.shields.io/github/release/akalongman/laravel-multilang.svg?style=flat-square)](https://github.com/akalongman/laravel-multilang/releases)\n[![Total Downloads](https://img.shields.io/packagist/dt/Longman/laravel-multilang.svg)](https://packagist.org/packages/longman/laravel-multilang)\n[![Downloads Month](https://img.shields.io/packagist/dm/Longman/laravel-multilang.svg)](https://packagist.org/packages/longman/laravel-multilang)\n[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n\n*This version of MultiLang package requires minimum PHP 7.0. \nFor older PHP versions use MultiLang [1.x](https://github.com/akalongman/laravel-multilang/releases/tag/1.3.3)*\n\nThis is a very useful package to integrate multi language (multi locale) functionality in Laravel 5.x.\nIt includes a ServiceProvider to register the multilang and Middleware for automatic modification routes like `http://site.com/en/your-routes`.\n\nThis package uses database for storing translations (it caches data on production environment for improving performance)\nAlso package automatically adds in database missing keys (on the local environment only).\n\n## Table of Contents\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Translating](#translating)\n    - [Blade Templates](#blade-templates)\n    - [URL Generation](#url-generation)\n    - [Text Scopes](#text-scopes)\n    - [Import/Export Texts](#importexport-texts)\n- [TODO](#todo)\n- [Troubleshooting](#troubleshooting)\n- [Contributing](#contributing)\n- [License](#license)\n- [Credits](#credits)\n\n\n## Installation\n\nInstall this package through [Composer](https://getcomposer.org/).\n\nEdit your project's `composer.json` file to require `longman/laravel-multilang`\n\nCreate *composer.json* file:\n```json\n{\n    \"name\": \"yourproject/yourproject\",\n    \"type\": \"project\",\n    \"require\": {\n        \"longman/laravel-multilang\": \"~2.0\"\n    }\n}\n```\nAnd run composer update\n\n**Or** run a command in your command line:\n\n    composer require longman/laravel-multilang\n\nIn Laravel the service provider and facade will automatically get registered. \n\nCopy the package config to your local config with the publish command:\n\n    php artisan vendor:publish --provider=\"Longman\\LaravelMultiLang\\MultiLangServiceProvider\"\n\nAfter run multilang migration command\n\n    php artisan multilang:migration\n\nIts creates multilang migration file in your database/migrations folder. After you can run\n\n    php artisan migrate\n\nAlso if you want automatically change locale depending on url (like `http://site.com/en/your-routes`)\nyou must add middleware in app/Http/Kernel.php\n\nI suggest add multilang after CheckForMaintenanceMode middleware\n```php\nprotected $middleware = [\n    \\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode::class,\n    \\Longman\\LaravelMultiLang\\Middleware\\MultiLang::class,\n];\n```\n\nIn your RoutesServiceProvider modify that:\n```php\nMultiLang::routeGroup(function($router) {\n    require app_path('Http/routes.php');\n});\n```\n\nor directly in app/Http/routes.php file add multilang group:\n```php\nMultiLang::routeGroup(function($router) {\n    // your routes and route groups here\n});\n```\n\nOr if you want only translate strings without automatic resolving locale and redirect, \nyou can manually set locale in your application like:\n```php\nApp::setLocale('en');\n```\n\n\n## Usage\n\n### Translating\nEverywhere in application you can use `t()` helper function like:\n\n```php\n$string = t('Your translatable string');\n```\n\nYou can use markers for dynamic texts and pass any data like\n```php\n$string = t('The :attribute must be a date after :date.', ['attribute' =\u003e 'Start Date', 'date' =\u003e '7 April 1986']);\n```\nwhich will be return `The Start Date must be a date after 7 April 1986.`\n\n### Blade Templates\nIn blade templates you can use just `@t()` notation like\n```php\n@t('Your translatable string')\n```\nwhich is equivalent to `{{ t('Your translatable string') }}`\n\n### URL Generation\nAlso you can use `lang_url()` helper function for appending current lang marker in urls automatically.\n\n```php\n$url = lang_url('users'); // which returns /en/users depending on your language (locale)\n```\n\nYou can force locale and get localized url for current url for example.\n\n```php\n$url = lang_url('users', [], null, 'ka'); // which returns /ka/users ignoring current locale\n```\nor\n```php\n$url = lang_url('en/users', [], null, 'ka'); // also returns /ka/users\n```\n\nAlso you use named routes via `lang_route()` function\n\n```php\n$url = lang_route('users'); // which returns en.users depending on your language (locale)\n```\n\nAlso `Request::locale()` always will return current locale.\n\n*Note*: Texts will be selected after firing Laravel's `LocaleUpdated` event. Therefore you should use MultiLang middleware, or manually set locale in the application.\n\n### Text Scopes\nIf you want group translations by some scope, in package available defining of scopes.\nFor example to define scope `admin` in application, you should call:\n\n```php\napp('multilang')-\u003esetScope('admin');\n```\n\nbefore setting the locale.\n\n*Note*: Default scope is `global`\n\n### Import/Export Texts\nFor versioning texts with source code (git/svn) and easy management, there is possible import texts from yml file and also export in the file.\n\nyml file format is:\n\n```yml\n-\n  key: 'authorization'\n  texts:\n    en: 'Authorization'\n    ge: 'ავტორიზაცია'\n-\n  key: 'registration'\n  texts:\n    en: 'Registration'\n    ge: 'რეგისტრაცია'\n```\n\nRun commands for possible options and more information:\n    \n    php artisan help multilang:import\n    \n    php artisan help multilang:export\n\n\n## TODO\n\nwrite more tests\n\n## Troubleshooting\n\nIf you like living on the edge, please report any bugs you find on the\n[laravel-multilang issues](https://github.com/akalongman/laravel-multilang/issues) page.\n\n## Contributing\n\nPull requests are welcome.\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for information.\n\n## License\n\nPlease see the [LICENSE](LICENSE.md) included in this repository for a full copy of the MIT license,\nwhich this project is licensed under.\n\n## Credits\n\n- [Avtandil Kikabidze aka LONGMAN](https://github.com/akalongman)\n\nFull credit list in [CREDITS](CREDITS)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakalongman%2Flaravel-multilang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakalongman%2Flaravel-multilang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakalongman%2Flaravel-multilang/lists"}