{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/10718","labels_url":"https://api.github.com/repos/laravel/framework/issues/10718/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/10718/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/10718/events","html_url":"https://github.com/laravel/framework/issues/10718","id":113151779,"number":10718,"title":"Translator->has cannot work due to fallback_locale","user":{"login":"llnk","id":1444881,"avatar_url":"https://avatars.githubusercontent.com/u/1444881?v=3","gravatar_id":"","url":"https://api.github.com/users/llnk","html_url":"https://github.com/llnk","followers_url":"https://api.github.com/users/llnk/followers","following_url":"https://api.github.com/users/llnk/following{/other_user}","gists_url":"https://api.github.com/users/llnk/gists{/gist_id}","starred_url":"https://api.github.com/users/llnk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/llnk/subscriptions","organizations_url":"https://api.github.com/users/llnk/orgs","repos_url":"https://api.github.com/users/llnk/repos","events_url":"https://api.github.com/users/llnk/events{/privacy}","received_events_url":"https://api.github.com/users/llnk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-24T11:20:44Z","updated_at":"2015-10-29T11:56:58Z","closed_at":null,"body":"If you need to check if a key is localized in a certain lang you can do: \r\n\r\n     $translator->has($id, $locale)) \r\n\r\nBut if $id is localized in the fallback_locale that method will return true since it is defined as:\r\n\r\n[Link to code](https://github.com/laravel/framework/blob/076a054b6c78888acb3d0b93030402dbf736d824/src/Illuminate/Translation/Translator.php#L61)\r\n\r\n    /**\r\n     * Determine if a translation exists.\r\n     *\r\n     * @param  string  $key\r\n     * @param  string  $locale\r\n     * @return bool\r\n     */\r\n    public function has($key, $locale = null)\r\n    {\r\n        return $this->get($key, [], $locale) !== $key;\r\n    }\r\n\r\nIt simply checks if `get` returns something different than $key (that is true when it fallbacks to another locale). The check should work in another way"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/152157043","html_url":"https://github.com/laravel/framework/issues/10718#issuecomment-152157043","issue_url":"https://api.github.com/repos/laravel/framework/issues/10718","id":152157043,"user":{"login":"llnk","id":1444881,"avatar_url":"https://avatars.githubusercontent.com/u/1444881?v=3","gravatar_id":"","url":"https://api.github.com/users/llnk","html_url":"https://github.com/llnk","followers_url":"https://api.github.com/users/llnk/followers","following_url":"https://api.github.com/users/llnk/following{/other_user}","gists_url":"https://api.github.com/users/llnk/gists{/gist_id}","starred_url":"https://api.github.com/users/llnk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/llnk/subscriptions","organizations_url":"https://api.github.com/users/llnk/orgs","repos_url":"https://api.github.com/users/llnk/repos","events_url":"https://api.github.com/users/llnk/events{/privacy}","received_events_url":"https://api.github.com/users/llnk/received_events","type":"User","site_admin":false},"created_at":"2015-10-29T11:56:58Z","updated_at":"2015-10-29T11:56:58Z","body":"Contex: I need a way to log whenever translation is used in a view doesn't exists (note: this should be logged by default). A possibile solution is:\r\n\r\n```\r\n  function trans_safe($id = null, $parameters = [], $domain = 'messages', $locale = null)\r\n  {\r\n    $translator = app('translator');\r\n\r\n    if (is_null($id)) {\r\n        return app('translator');\r\n    }\r\n\r\n    if (! $translator->has($id, $locale)) {\r\n        \\Log::warning(\"$id doesn't exist... \");\r\n    }\r\n\r\n    return app('translator')->trans($id, $parameters, $domain, $locale);\r\n  }\r\n```\r\n\r\nSo instead to use {{ trans('...') }} in a view you can use trans_safe('...') and get a log whenever that phrase hasn't been translated yet. The problem is that with fallback_locale you cannot get the right results.\r\n\r\nA possibile workaround temporarily would be to set a nonexisting locale:\r\n\r\n     config(['app.fallback_locale' => '--']);"}}