{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/Docs/pulls/comments/53896776","id":53896776,"diff_hunk":"@@ -1,8 +1,285 @@\n-.. include:: /../common/stub-topic.txt\n+ASP.NET Core Internationalization: Localization and Globalization \n+==================================================================\n \n-|stub-icon| Localization\n-========================\n+By `Rick Anderson`_ with assistance from `Damien Bowden <https://twitter.com/damien_bod>`_, `Bart Calixto <https://twitter.com/bartmax>`_, and `Nadeem Afana <https://twitter.com/NadeemAfana>`__ \n \n-.. include:: /../common/stub-notice.txt\n+Creating a multilingual website with ASP.NET Core will allow your site to reach a wider audience. ASP.NET has :doc:`/fundamentals/request-features` that provide support for localizing into different languages and cultures.\n \n-.. _issue: https://github.com/aspnet/Docs/issues/653\n\\ No newline at end of file\n+This sample is based on the **Localization.StarterWeb** project on `GitHub <https://github.com/aspnet/entropy>`__.\n+\n+.. contents:: In this article:\n+  :local:\n+  :depth: 1\n+  \n+.. note:: Currently, resource files are not read when the project is run from Visual Studio. See `this issue <https://github.com/aspnet/dnx/issues/3047>`_ for more information. Until the issue with Visual Studio is addressed, you can test the project by running it from the command line.\n+\n+IStringLocalizer\n+---------------------------------\n+\n+Introduced in ASP.NET Core, ``IStringLocalizer`` was architected to improve productivity when developing localized apps. \n+\n+The simple interface has an indexer and an ``IEnumerable`` for returning localized strings. Unlike previous localization approaches, ``IStringLocalizer`` doesn't require you to store the default language strings in a resource file. You can develop an app targeted for localization and not need to create resource files early in development. We anticipate that many developers will **not** create a default language resource file. In previous versions of ASP.NET, you had to move all your localization strings into a resource (.resx) file and change your app everywhere the strings were used, even for the default language. You no longer need to move your localized strings, you simply wrap them.\n+\n+.. literalinclude:: localization/sample/Controllers/AboutController.cs\n+  :language: c#\n+\n+In the code above, the ``IStringLocalizer`` implementation comes from :doc:`/fundamentals/dependency-injection`. If the localized value of \"About Title\" is not found, then the indexer key is returned, that is, the string \"About Title\". You can leave the default language literal strings in the app and wrap them in the localizer. You can develop your app with your default language and prepare it for the localization step without first creating a default resource file. Alternatively, you can use the traditional approach and provide a key to retrieve the default language string. For many developers the new workflow of not having a default language \"resx\" file and simply wrapping the string literals can reduce the overhead of localizing an app. Other developers will prefer the traditional work flow as it can make it easier to work with longer string literals and make it easier to update localized strings.\n+\n+Use the ``IHtmlLocalizer`` implementation for resources that contain markup. ``IHtmlLocalizer`` HTML encodes arguments that are formatted in the resource string, but not the resource string. In the sample highlighted below, only the ``name`` parameter is HTML encoded.\n+\n+.. literalinclude:: localization/sample/Controllers/BookController.cs\n+  :language: c#\n+  :linenos:\n+  :lines: 1-23\n+  :emphasize-lines: 3,5,20 \n+\n+At the lowest level, you can get ``IStringLocalizerFactory`` out of :doc:`/fundamentals/dependency-injection`:\n+\n+.. literalinclude:: localization/sample/Controllers/TestController.cs\n+  :language: c#\n+  :linenos:\n+  :lines: 9-27\n+  :emphasize-lines: 6-11 \n+  :dedent: 3\n+\n+The code above demonstrates each of the two factory create methods. \n+\n+You can partition your localized strings by controller, area, or have just one container. In the sample app, a dummy class named ``SharedResource`` is used to contain shared resources. Some developers use the ``Startup`` class to contain global or shared strings.  In the sample below, the ``ZebraController`` and the ``SharedResource`` localizers are used:\n+\n+.. literalinclude:: localization/sample/Controllers/ZebraController.cs\n+  :language: c#\n+  :linenos:\n+  :lines: 9-27\n+  :dedent: 3\n+\n+View localization\n+--------------------\n+\n+The ``IViewLocalizer`` service provides localized strings for a view. The ``ViewLocalizer`` class implements this interface and finds the resource location from the view file path. The following code shows how to use the default implementation of ``IViewLocalizer``:\n+\n+.. literalinclude:: localization/sample/Views/Home/About.cshtml\n+  :language: HTML\n+  \n+The default implementation of ``IViewLocalizer`` finds the resource file based on the view name, there is no option to use a global shared resource file. ``ViewLocalizer`` implements the localizer using ``IHtmlLocalizer``, so Razor doesn't HTML encode the localized string. You can parameterize resource strings and ``IViewLocalizer`` will HTML encode the parameters, but not the resource string. Consider the following Razor markup:","path":"aspnet/fundamentals/localization.rst","position":69,"original_position":69,"commit_id":"6afba5241a6fb93082c1b76ebf40c396badf7c32","original_commit_id":"6afba5241a6fb93082c1b76ebf40c396badf7c32","user":{"login":"danroth27","id":1874516,"avatar_url":"https://avatars.githubusercontent.com/u/1874516?v=3","gravatar_id":"","url":"https://api.github.com/users/danroth27","html_url":"https://github.com/danroth27","followers_url":"https://api.github.com/users/danroth27/followers","following_url":"https://api.github.com/users/danroth27/following{/other_user}","gists_url":"https://api.github.com/users/danroth27/gists{/gist_id}","starred_url":"https://api.github.com/users/danroth27/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danroth27/subscriptions","organizations_url":"https://api.github.com/users/danroth27/orgs","repos_url":"https://api.github.com/users/danroth27/repos","events_url":"https://api.github.com/users/danroth27/events{/privacy}","received_events_url":"https://api.github.com/users/danroth27/received_events","type":"User","site_admin":false},"body":"> The default implementation of ``IViewLocalizer`` finds the resource file based on the view name, there is no option to use a global shared resource file.\r\n\r\nThe default implementation of ``IViewLocalizer`` finds the resource file based on the view name. There is no option to use a global shared resource file.","created_at":"2016-02-24T05:45:28Z","updated_at":"2016-02-24T05:45:28Z","html_url":"https://github.com/aspnet/Docs/pull/1002#discussion_r53896776","pull_request_url":"https://api.github.com/repos/aspnet/Docs/pulls/1002","_links":{"self":{"href":"https://api.github.com/repos/aspnet/Docs/pulls/comments/53896776"},"html":{"href":"https://github.com/aspnet/Docs/pull/1002#discussion_r53896776"},"pull_request":{"href":"https://api.github.com/repos/aspnet/Docs/pulls/1002"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/Docs/pulls/1002","id":60029082,"html_url":"https://github.com/aspnet/Docs/pull/1002","diff_url":"https://github.com/aspnet/Docs/pull/1002.diff","patch_url":"https://github.com/aspnet/Docs/pull/1002.patch","issue_url":"https://api.github.com/repos/aspnet/Docs/issues/1002","number":1002,"state":"open","locked":false,"title":"initial loc doc","user":{"login":"Rick-Anderson","id":3605364,"avatar_url":"https://avatars.githubusercontent.com/u/3605364?v=3","gravatar_id":"","url":"https://api.github.com/users/Rick-Anderson","html_url":"https://github.com/Rick-Anderson","followers_url":"https://api.github.com/users/Rick-Anderson/followers","following_url":"https://api.github.com/users/Rick-Anderson/following{/other_user}","gists_url":"https://api.github.com/users/Rick-Anderson/gists{/gist_id}","starred_url":"https://api.github.com/users/Rick-Anderson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rick-Anderson/subscriptions","organizations_url":"https://api.github.com/users/Rick-Anderson/orgs","repos_url":"https://api.github.com/users/Rick-Anderson/repos","events_url":"https://api.github.com/users/Rick-Anderson/events{/privacy}","received_events_url":"https://api.github.com/users/Rick-Anderson/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-02-20T00:49:37Z","updated_at":"2016-02-24T05:45:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7843b61b5d029146148c6a98d44251b47693753","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/Docs/pulls/1002/commits","review_comments_url":"https://api.github.com/repos/aspnet/Docs/pulls/1002/comments","review_comment_url":"https://api.github.com/repos/aspnet/Docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/Docs/issues/1002/comments","statuses_url":"https://api.github.com/repos/aspnet/Docs/statuses/6afba5241a6fb93082c1b76ebf40c396badf7c32","head":{"label":"aspnet:riande-loc8","ref":"riande-loc8","sha":"6afba5241a6fb93082c1b76ebf40c396badf7c32","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":28239455,"name":"Docs","full_name":"aspnet/Docs","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Docs","description":"Documentation for ASP.NET 5","fork":false,"url":"https://api.github.com/repos/aspnet/Docs","forks_url":"https://api.github.com/repos/aspnet/Docs/forks","keys_url":"https://api.github.com/repos/aspnet/Docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Docs/teams","hooks_url":"https://api.github.com/repos/aspnet/Docs/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Docs/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Docs/events","assignees_url":"https://api.github.com/repos/aspnet/Docs/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Docs/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Docs/tags","blobs_url":"https://api.github.com/repos/aspnet/Docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Docs/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Docs/languages","stargazers_url":"https://api.github.com/repos/aspnet/Docs/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Docs/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Docs/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Docs/subscription","commits_url":"https://api.github.com/repos/aspnet/Docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Docs/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Docs/merges","archive_url":"https://api.github.com/repos/aspnet/Docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Docs/downloads","issues_url":"https://api.github.com/repos/aspnet/Docs/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Docs/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Docs/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Docs/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Docs/releases{/id}","deployments_url":"https://api.github.com/repos/aspnet/Docs/deployments","created_at":"2014-12-19T17:38:02Z","updated_at":"2016-02-22T22:58:29Z","pushed_at":"2016-02-24T01:50:48Z","git_url":"git://github.com/aspnet/Docs.git","ssh_url":"git@github.com:aspnet/Docs.git","clone_url":"https://github.com/aspnet/Docs.git","svn_url":"https://github.com/aspnet/Docs","homepage":null,"size":41370,"stargazers_count":392,"watchers_count":392,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":639,"mirror_url":null,"open_issues_count":138,"forks":639,"open_issues":138,"watchers":392,"default_branch":"master"}},"base":{"label":"aspnet:1.0.0-rc2","ref":"1.0.0-rc2","sha":"c7ee1b1996ddfa3b38fa79b7160d552e69cf2b6c","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":28239455,"name":"Docs","full_name":"aspnet/Docs","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/Docs","description":"Documentation for ASP.NET 5","fork":false,"url":"https://api.github.com/repos/aspnet/Docs","forks_url":"https://api.github.com/repos/aspnet/Docs/forks","keys_url":"https://api.github.com/repos/aspnet/Docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/Docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/Docs/teams","hooks_url":"https://api.github.com/repos/aspnet/Docs/hooks","issue_events_url":"https://api.github.com/repos/aspnet/Docs/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/Docs/events","assignees_url":"https://api.github.com/repos/aspnet/Docs/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/Docs/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/Docs/tags","blobs_url":"https://api.github.com/repos/aspnet/Docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/Docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/Docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/Docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/Docs/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/Docs/languages","stargazers_url":"https://api.github.com/repos/aspnet/Docs/stargazers","contributors_url":"https://api.github.com/repos/aspnet/Docs/contributors","subscribers_url":"https://api.github.com/repos/aspnet/Docs/subscribers","subscription_url":"https://api.github.com/repos/aspnet/Docs/subscription","commits_url":"https://api.github.com/repos/aspnet/Docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/Docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/Docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/Docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/Docs/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/Docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/Docs/merges","archive_url":"https://api.github.com/repos/aspnet/Docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/Docs/downloads","issues_url":"https://api.github.com/repos/aspnet/Docs/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/Docs/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/Docs/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/Docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/Docs/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/Docs/releases{/id}","deployments_url":"https://api.github.com/repos/aspnet/Docs/deployments","created_at":"2014-12-19T17:38:02Z","updated_at":"2016-02-22T22:58:29Z","pushed_at":"2016-02-24T01:50:48Z","git_url":"git://github.com/aspnet/Docs.git","ssh_url":"git@github.com:aspnet/Docs.git","clone_url":"https://github.com/aspnet/Docs.git","svn_url":"https://github.com/aspnet/Docs","homepage":null,"size":41370,"stargazers_count":392,"watchers_count":392,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":639,"mirror_url":null,"open_issues_count":138,"forks":639,"open_issues":138,"watchers":392,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/Docs/pulls/1002"},"html":{"href":"https://github.com/aspnet/Docs/pull/1002"},"issue":{"href":"https://api.github.com/repos/aspnet/Docs/issues/1002"},"comments":{"href":"https://api.github.com/repos/aspnet/Docs/issues/1002/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/Docs/pulls/1002/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/Docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/Docs/pulls/1002/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/Docs/statuses/6afba5241a6fb93082c1b76ebf40c396badf7c32"}}}}