Skip to content

Commit

Permalink
feat: Add toggle group translations for multiple locales (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharanish-v committed May 22, 2024
1 parent 401e48c commit db113d2
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 3 deletions.
4 changes: 4 additions & 0 deletions locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"selectBlockTypeTooltip": "Select block type",
"placeholder": "Block type"
},
"toggleGroup":"toggle group",
"removeBold": "Remove bold",
"bold": "Bold",
"removeItalic": "Remove italic",
Expand Down Expand Up @@ -97,5 +98,8 @@
"codeBlock": {
"language": "Code block language",
"selectLanguage": "Select code block language"
},
"contentArea":{
"editableMarkdown": "editable markdown"
}
}
4 changes: 4 additions & 0 deletions locales/pt-br/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"selectBlockTypeTooltip": "Selecione o tipo de bloco de texto",
"placeholder": "Bloco de texto"
},
"toggleGroup": "Grupo de alternância",
"removeBold": "Remover negrito",
"bold": "Negrito",
"removeItalic": "Remover itálico",
Expand Down Expand Up @@ -97,5 +98,8 @@
"codeBlock": {
"language": "Linguagem do bloco de código",
"selectLanguage": "Selecionar linguagem do bloco de código"
},
"contentArea":{
"editableMarkdown": "Markdown editável"
}
}
4 changes: 4 additions & 0 deletions locales/uk-ua/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"selectBlockTypeTooltip": "Виберіть тип блоку",
"placeholder": "Тип блоку"
},
"toggleGroup": "Група перемикачів",
"removeBold": "Прибрати жирний шрифт",
"bold": "Жирний шрифт",
"removeItalic": "Видалити курсив",
Expand Down Expand Up @@ -97,6 +98,9 @@
"codeBlock": {
"language": "Мова блоку коду",
"selectLanguage": "Виберіть мову блоку коду"
},
"contentArea":{
"editableMarkdown": "редагований маркдаун"
}
}

4 changes: 4 additions & 0 deletions locales/zh-cn/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"selectBlockTypeTooltip": "选择块类型",
"placeholder": "块类型"
},
"toggleGroup": "切换组",
"removeBold": "移除粗体",
"bold": "粗体",
"removeItalic": "移除斜体",
Expand Down Expand Up @@ -97,5 +98,8 @@
"codeBlock": {
"language": "代码块语言",
"selectLanguage": "选择代码块语言"
},
"contentArea":{
"editableMarkdown": "可编辑的 Markdown"
}
}
4 changes: 4 additions & 0 deletions locales/zh-tw/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"selectBlockTypeTooltip": "選擇塊類型",
"placeholder": "塊類型"
},
"toggleGroup": "切換群組",
"removeBold": "移除粗體",
"bold": "粗體",
"removeItalic": "移除斜體",
Expand Down Expand Up @@ -97,5 +98,8 @@
"codeBlock": {
"language": "程式碼區塊語言",
"selectLanguage": "選擇程式碼區塊語言"
},
"contentArea":{
"editableMarkdown": "可編輯的 Markdown"
}
}
7 changes: 6 additions & 1 deletion src/MDXEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
rootEditor$,
setMarkdown$,
topAreaChildren$,
useTranslation,
viewMode$
} from './plugins/core'

Expand Down Expand Up @@ -42,6 +43,7 @@ const LexicalProvider: React.FC<{
}

const RichTextEditor: React.FC = () => {
const t = useTranslation()
const [contentEditableClassName, composerChildren, topAreaChildren, editorWrappers, placeholder] = useCellValues(
contentEditableClassName$,
composerChildren$,
Expand All @@ -58,7 +60,10 @@ const RichTextEditor: React.FC = () => {
<div className={classNames(styles.rootContentEditableWrapper, 'mdxeditor-root-contenteditable')}>
<RichTextPlugin
contentEditable={
<ContentEditable className={classNames(styles.contentEditable, contentEditableClassName)} ariaLabel="editable markdown" />
<ContentEditable
className={classNames(styles.contentEditable, contentEditableClassName)}
ariaLabel={t('contentArea.editableMarkdown', 'editable markdown')}
/>
}
placeholder={
<div className={classNames(styles.contentEditable, styles.placeholder, contentEditableClassName)}>
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/toolbar/primitives/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react'
import styles from '../../../styles/ui.module.css'
import { TooltipWrap } from './TooltipWrap'
import { SelectButtonTrigger, SelectContent, SelectItem } from './select'
import { EditorInFocus, editorInFocus$, readOnly$ } from '../../core'
import { EditorInFocus, editorInFocus$, readOnly$, useTranslation } from '../../core'
import { useCellValue } from '@mdxeditor/gurx'

//
Expand Down Expand Up @@ -152,10 +152,12 @@ export const SingleChoiceToggleGroup = <T extends string>({
value: T | ''
className?: string
}) => {
const t = useTranslation()

Check failure on line 156 in src/plugins/toolbar/primitives/toolbar.tsx

View workflow job for this annotation

GitHub Actions / Release

Delete `··`
return (
<div className={styles.toolbarGroupOfGroups}>
<RadixToolbar.ToggleGroup
aria-label="toggle group"
aria-label={t('toolbar.toggleGroup', 'toggle group')}
type="single"
className={classNames(styles.toolbarToggleSingleGroup, className)}
onValueChange={onChange}
Expand Down

0 comments on commit db113d2

Please sign in to comment.