{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/16453","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/16453/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/16453/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/16453/events","html_url":"https://github.com/laravel/framework/pull/16453","id":190164328,"number":16453,"title":"[5.4][WIP] Localized routes","user":{"login":"themsaid","id":4332182,"avatar_url":"https://avatars.githubusercontent.com/u/4332182?v=3","gravatar_id":"","url":"https://api.github.com/users/themsaid","html_url":"https://github.com/themsaid","followers_url":"https://api.github.com/users/themsaid/followers","following_url":"https://api.github.com/users/themsaid/following{/other_user}","gists_url":"https://api.github.com/users/themsaid/gists{/gist_id}","starred_url":"https://api.github.com/users/themsaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/themsaid/subscriptions","organizations_url":"https://api.github.com/users/themsaid/orgs","repos_url":"https://api.github.com/users/themsaid/repos","events_url":"https://api.github.com/users/themsaid/events{/privacy}","received_events_url":"https://api.github.com/users/themsaid/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-17T21:07:24Z","updated_at":"2016-11-18T11:47:24Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/laravel/framework/pulls/16453","html_url":"https://github.com/laravel/framework/pull/16453","diff_url":"https://github.com/laravel/framework/pull/16453.diff","patch_url":"https://github.com/laravel/framework/pull/16453.patch"},"body":"This is a WIP attempt to add support for multilingual routes in Laravel 5.4, I've been trying to apply the least changes and keep things in place.\r\n\r\n- A key to be added to `config/app.php` with the name `locales` which holds an array of locales the application may support.\r\n- A `\\Illuminate\\Http\\Middleware\\LocalizeRequest` middleware need to be added to the global middleware stack *only* if the application supports localization.\r\n\r\nThis middleware will try to guess the desired locale based on the request URI, once a locale is found we inform the request about it using `Request::setLocale()` which will make sure the router skips the locale information from the given URI before attempting to match any requests with the application defined routes.\r\n\r\nSo if the URL is `ar/contacts-us/form` the router will find a match with the route `/contact-us/form`, without this middleware an HTTPNotFound exception would be thrown because the route definition doesn't match the request path.\r\n\r\nWith this in hand, the URL generator will prepend the locale string to all generated URLs in case the locale isn't the default one, so `url('some/path')` will be generated as `http://app.dev/ar/some/path` in case `ar` is not the default locale.\r\n\r\nThe current way the middleware guesses the locale is by looking at the first segment of the URL and see if it matches any of the locales registered in the application, there's another scenario where the locale is given as a sub domain `ar.laravel.com` but this PR doesn't tackle this at the moment."},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/261513896","html_url":"https://github.com/laravel/framework/pull/16453#issuecomment-261513896","issue_url":"https://api.github.com/repos/laravel/framework/issues/16453","id":261513896,"user":{"login":"brunogaspar","id":2285372,"avatar_url":"https://avatars.githubusercontent.com/u/2285372?v=3","gravatar_id":"","url":"https://api.github.com/users/brunogaspar","html_url":"https://github.com/brunogaspar","followers_url":"https://api.github.com/users/brunogaspar/followers","following_url":"https://api.github.com/users/brunogaspar/following{/other_user}","gists_url":"https://api.github.com/users/brunogaspar/gists{/gist_id}","starred_url":"https://api.github.com/users/brunogaspar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brunogaspar/subscriptions","organizations_url":"https://api.github.com/users/brunogaspar/orgs","repos_url":"https://api.github.com/users/brunogaspar/repos","events_url":"https://api.github.com/users/brunogaspar/events{/privacy}","received_events_url":"https://api.github.com/users/brunogaspar/received_events","type":"User","site_admin":false},"created_at":"2016-11-18T11:47:24Z","updated_at":"2016-11-18T11:47:24Z","body":"I think the locale could be determine by either `route` (prefix or subdomain), `session` or through what the `browser` returns.\r\n\r\nThis can be a single middleware with a switch on the config file or multiple middlewares and we would choose what best works for our application.\r\n\r\nGood job so far @themsaid !"}}
{"actor":{"display_login":"brunogaspar"}}