-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into intl-purposes-desc
- Loading branch information
Showing
17 changed files
with
20,831 additions
and
24,447 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
npmPublishAccess: public | ||
compressionLevel: mixed | ||
|
||
enableGlobalCache: false | ||
|
||
plugins: | ||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs | ||
spec: "@yarnpkg/plugin-interactive-tools" | ||
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs | ||
spec: "@yarnpkg/plugin-typescript" | ||
npmPublishAccess: public | ||
|
||
yarnPath: .yarn/releases/yarn-3.4.1.cjs | ||
yarnPath: .yarn/releases/yarn-4.5.1.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export const VERSION = process.env.VERSION as string; | ||
export const CONSENT_OPTIONS = { confirmed: true, prompted: true }; | ||
export const CSS_RESET = ':host{all:initial}'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { TranslatedMessages } from '@transcend-io/internationalization'; | ||
|
||
/** | ||
* Takes in a set of messages which may or may not contain HTML and replaces any | ||
* HTML tags so that format.js can successfully internationalize them without | ||
* running into parsing errors and using the fallback option | ||
* | ||
* @param messages - Raw precompiled messages (sometimes containing html tags) | ||
* @returns Messages with all HTML opening/closing tags substituted and the variables to replace those substitutions | ||
*/ | ||
export function substituteHtml(messages: TranslatedMessages): { | ||
/** The set of messages with their HTML opening/closing tags substituted */ | ||
substitutedMessages: TranslatedMessages; | ||
/** The set of variables used to replace the substitutions with their corresponding HTML opening/closing tags */ | ||
tagVariables: Record<string, string>; | ||
} { | ||
const substitutedMessages = { ...messages }; | ||
const tagVariables: Record<string, string> = {}; | ||
Object.entries(substitutedMessages).forEach(([key, rawMessage]) => { | ||
let placeholderMessage = rawMessage; | ||
const htmlTags = [...rawMessage.matchAll(/<[^>]+>/g)].flat(); | ||
htmlTags.forEach((tag, idx) => { | ||
const uniqKey = key.replaceAll('.', '_'); | ||
placeholderMessage = placeholderMessage.replace( | ||
tag, | ||
`{tcm_${uniqKey}_tag_match_${idx}}`, | ||
); | ||
tagVariables[`tcm_${uniqKey}_tag_match_${idx}`] = tag; | ||
}); | ||
substitutedMessages[key] = placeholderMessage; | ||
}); | ||
return { substitutedMessages, tagVariables }; | ||
} |
Oops, something went wrong.