summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-02-10 16:58:45 +0100
committerArmand Philippot <git@armandphilippot.com>2022-02-10 16:59:56 +0100
commit0565c019c77e4c67876dec5bd099a9de4564da30 (patch)
tree50e122b07d6d5e3987d7a960b0a32ee4ed200daa /src/utils
parent82de06b1bda8a9213d1147029e8a404084bf486e (diff)
fix(prism): translate toolbar buttons on single article pages
The translation was not always loaded the first time. So I decided to put the prism attributes manually instead.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/helpers/prism.ts49
1 files changed, 0 insertions, 49 deletions
diff --git a/src/utils/helpers/prism.ts b/src/utils/helpers/prism.ts
index 1004a84..bc84c91 100644
--- a/src/utils/helpers/prism.ts
+++ b/src/utils/helpers/prism.ts
@@ -1,5 +1,3 @@
-import { IntlShape } from 'react-intl';
-
/**
* Check if the current block has a defined language.
* @param classList - A list of class.
@@ -35,50 +33,3 @@ export const addPrismClasses = () => {
}
});
};
-
-/**
- * Translate the PrismJS Copy to clipboard button.
- */
-export const translateCopyButton = (locale: string, intl: IntlShape) => {
- const articles = document.getElementsByTagName('article');
- const copyText = intl.formatMessage({
- defaultMessage: 'Copy',
- description: 'Prism: copy button text (no clicked)',
- });
- const copiedText = intl.formatMessage({
- defaultMessage: 'Copied!',
- description: 'Prism: copy button text (clicked)',
- });
- const errorText = intl.formatMessage({
- defaultMessage: 'Use Ctrl+c to copy',
- description: 'Prism: error text',
- });
-
- Array.from(articles).forEach((article) => {
- article.setAttribute('lang', locale);
- article.setAttribute('data-prismjs-copy', copyText);
- article.setAttribute('data-prismjs-copy-success', copiedText);
- article.setAttribute('data-prismjs-copy-error', errorText);
- });
-};
-
-/**
- * Translate the PrismJS color-scheme button.
- */
-export const translateToggleButton = (locale: string, intl: IntlShape) => {
- const articles = document.getElementsByTagName('article');
- const darkTheme = intl.formatMessage({
- defaultMessage: 'Toggle Dark Theme',
- description: 'Prism: toggle dark theme button text',
- });
- const lightTheme = intl.formatMessage({
- defaultMessage: 'Toggle Light Theme',
- description: 'Prism: toggle light theme button text',
- });
-
- Array.from(articles).forEach((article) => {
- article.setAttribute('lang', locale);
- article.setAttribute('data-prismjs-color-scheme-dark', darkTheme);
- article.setAttribute('data-prismjs-color-scheme-light', lightTheme);
- });
-};