5 lines
6.3 KiB
JSON
5 lines
6.3 KiB
JSON
{
|
|
"id": "api/localize/loadTranslations",
|
|
"title": "loadTranslations",
|
|
"contents": "\n\n<article>\n <div class=\"breadcrumb-container\">\n <div class=\"breadcrumb\">\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"BreadcrumbList\",\n \"itemListElement\": [\n { \"@type\": \"ListItem\", \"position\": 1, \"item\": { \"@id\": \"https://angular.io//api\", \"name\": \"API\" } },\n { \"@type\": \"ListItem\", \"position\": 2, \"item\": { \"@id\": \"https://angular.io/api/localize\", \"name\": \"@angular/localize\" } },\n { \"@type\": \"ListItem\", \"position\": 3, \"item\": { \"@id\": \"https://angular.io/api/localize/loadTranslations\", \"name\": \"loadTranslations\" } }\n ]\n }\n </script>\n <a href=\"/api\">API</a> > <a href=\"api/localize\">@angular/localize</a>\n </div>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/localize/src/translate.ts?message=docs(localize)%3A%20describe%20your%20change...#L18-L69\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/localize/src/translate.ts#L18-L69\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n \n <header class=\"api-header\">\n <h1 id=\"loadtranslations\">loadTranslations<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/localize/loadTranslations#loadtranslations\"><i class=\"material-icons\">link</i></a></h1>\n \n <label class=\"api-type-label function\">function</label>\n \n \n \n </header>\n \n <aio-toc class=\"embedded\"></aio-toc>\n\n <div class=\"api-body\">\n \n <section class=\"short-description\">\n <p>Load translations for use by <code><a href=\"api/localize/init/$localize\" class=\"code-anchor\">$localize</a></code>, if doing runtime translation.</p>\n\n <p><a href=\"api/localize/loadTranslations#description\">See more...</a></p>\n </section>\n \n \n \n\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"> <span class=\"member-name\"><a href=\"api/localize/loadTranslations\" class=\"code-anchor\">loadTranslations</a></span>(translations: Record<string, string>)</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters\">Parameters</h6>\n <table class=\"is-full-width list-table parameters-table function-overload-parameters\">\n <tbody>\n \n <tr class=\"function-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>translations</code>\n </td>\n <td class=\"param-type\"><code>Record<string, string=\"\"></string,></code></td>\n <td class=\"param-description\">\n <p>A map from message ID to translated message.</p>\n<p>These messages are processed and added to a lookup based on their <code>MessageId</code>.</p>\n\n </td>\n </tr>\n </tbody>\n</table>\n\n \n\n\n \n\n \n</div>\n\n\n \n<section class=\"see-also\">\n <h2 id=\"see-also\">See also<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/localize/loadTranslations#see-also\"><i class=\"material-icons\">link</i></a></h2>\n <ul>\n \n <li><p><code><a href=\"api/localize/clearTranslations\" class=\"code-anchor\">clearTranslations</a>()</code> for removing translations loaded using this function.</p>\n</li>\n <li><p><code><a href=\"api/localize/init/$localize\" class=\"code-anchor\">$localize</a></code> for tagging messages as needing to be translated.</p>\n</li>\n </ul>\n</section>\n\n\n \n\n<section class=\"description\">\n <h2 id=\"description\">Description<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/localize/loadTranslations#description\"><i class=\"material-icons\">link</i></a></h2>\n <p>If the <code><a href=\"api/localize/init/$localize\" class=\"code-anchor\">$localize</a></code> tagged strings are not going to be replaced at compiled time, it is possible\nto load a set of translations that will be applied to the <code><a href=\"api/localize/init/$localize\" class=\"code-anchor\">$localize</a></code> tagged strings at runtime,\nin the browser.</p>\n<p>Loading a new translation will overwrite a previous translation if it has the same <code>MessageId</code>.</p>\n<p>Note that <code><a href=\"api/localize/init/$localize\" class=\"code-anchor\">$localize</a></code> messages are only processed once, when the tagged string is first\nencountered, and does not provide dynamic language changing without refreshing the browser.\nLoading new translations later in the application life-cycle will not change the translated text\nof messages that have already been translated.</p>\n<p>The message IDs and translations are in the same format as that rendered to \"simple JSON\"\ntranslation files when extracting messages. In particular, placeholders in messages are rendered\nusing the <code>{$PLACEHOLDER_NAME}</code> syntax. For example the message from the following template:</p>\n<code-example language=\"html\">\n<div i18n>pre<span>inner-pre<b>bold</b>inner-post</span>post</div>\n</code-example>\n<p>would have the following form in the <code>translations</code> map:</p>\n<code-example language=\"ts\">\n{\n \"2932901491976224757\":\n \"pre{$START_TAG_SPAN}inner-pre{$START_BOLD_TEXT}bold{$CLOSE_BOLD_TEXT}inner-post{$CLOSE_TAG_SPAN}post\"\n}\n</code-example>\n\n \n</section>\n\n\n\n \n\n\n </div>\n</article>\n\n<!-- links to this doc:\n - api/localize\n - api/localize/clearTranslations\n-->\n<!-- links from this doc:\n - /api\n - api/localize\n - api/localize/clearTranslations\n - api/localize/init/$localize\n - api/localize/loadTranslations#description\n - api/localize/loadTranslations#loadtranslations\n - api/localize/loadTranslations#see-also\n - https://github.com/angular/angular/edit/master/packages/localize/src/translate.ts?message=docs(localize)%3A%20describe%20your%20change...#L18-L69\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/localize/src/translate.ts#L18-L69\n-->"
|
|
} |