From 3735e17bb981826bb24b06de063cdcc9537549ff Mon Sep 17 00:00:00 2001 From: Danny Gleckler Date: Fri, 23 Aug 2024 10:57:30 -0400 Subject: [PATCH] fix: Add advanced formatting docs (#190) * Add advanced formatting docs * Use localizeMarkup --- README.md | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index df00520..17d4d1f 100644 --- a/README.md +++ b/README.md @@ -340,16 +340,38 @@ Similarly `` *emphasizes* a particular piece of text (browsers show this vis Example: -```json +```javascript { - "myMessage": "This is bold but not all that important." + myMessage: "This is bold but not all that important." } ``` +#### Advanced Formatting + +More advanced formatting can be achieved by providing replacement methods for custom tags, which are similar to arguments: + ```javascript -localizer.localizeHTML('myMessage'); +{ + goHome: "Go home" +} ``` +Then, import `localizeMarkup`: +```javascript +import { localizeMarkup } from '@brightspace-ui/intl/lib/localize.js'; +``` + +and provide a tag replacement method: +```javascript +localizer.localizeHTML('goHome', { + homeLink: chunks => localizeMarkup`${chunks}` +}); +``` +In addition to the Basic Formatting elements, these additional elements may also be used in replacement methods: + +* `` +* `` + ### `onResourcesChange` Provide an `onResourcesChange` callback function to perform tasks when the document language is changed and updated resources are available: