Skip to content

Commit

Permalink
[4.1] Language of Parts [a11y]
Browse files Browse the repository at this point in the history
This PR is a draft to implement and showcase the new language of parts feature in tinyMCE

It has been made to 4.1 as its a new feature

This PR requires joomla#35605 which at the time of this PR has not been merged into 4.1dev

This is a replacement PR of joomla#30939

This wraps the desired text in span tags with a lang attribute for the specified language. Unspecified text is assumed to be written in the page's language. This helps the resulting text comply with WCAG 2.0 3.1.2 Language of Parts: "The human language of each passage or phrase in the content can be programmatically determined..."

If you have customised your tinymce editor toolbar you will need to edit the toolbar again to include this button.

The need for this is based on the EU funded research project for improving the process of creating accessible content by authors https://accessibilitycluster.com/about

You can view a video that demonstrates the benefits of this feature https://www.youtube.com/watch?v=BY9_xhjtLV4 and read the [Technical Sepecification](https://www.dropbox.com/s/mbzh30rdt0c0gqa/Technical%20specification%20-%20Change%20language%20%28We4Authors%20Cluster%29.pdf) that the research project produced.

This PR is only a draft

The remaining task is to decide
- which languages to list
- if they should be translatable
- should they be fr for fr-FR
- or should the list of languages be user selectable in the tinymce plugin configuration

In addition the research project recommended that there should be some form of visible indicator to the content author that a piece of text has been marked as being in a specific language. TinyMCE have not implemented this (yet) but I think we could do it with some css?

cc @chmst
  • Loading branch information
brianteeman committed Sep 19, 2021
1 parent 4b2a75e commit 21c5885
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions plugins/editors/tinymce/tinymce.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,15 @@ public function onDisplay(
array('title' => 'Tag', 'value' => 'tag'),
);

$scriptOptions['content_langs'] = array(
array('title' => 'English', 'code' => 'en-GB'),
array('title' => 'Spanish', 'code' => 'es'),
array('title' => 'French', 'code' => 'fr'),
array('title' => 'German', 'code' => 'de'),
array('title' => 'Portuguese', 'code' => 'pt'),
array('title' => 'Chinese', 'code' => 'sh'),
);

$options['tinyMCE']['default'] = $scriptOptions;

$doc->addScriptOptions('plg_editor_tinymce', $options);
Expand Down Expand Up @@ -984,6 +993,8 @@ public static function getKnownButtons()
'pastetext' => array('label' => 'Paste as text', 'plugin' => 'paste'),
'removeformat' => array('label' => 'Clear formatting'),

'language' => array('label' => 'Language'),

// Buttons from the plugins
'anchor' => array('label' => 'Anchor', 'plugin' => 'anchor'),
'hr' => array('label' => 'Horizontal line', 'plugin' => 'hr'),
Expand Down Expand Up @@ -1074,6 +1085,7 @@ public static function getToolbarPreset()
'cut', 'copy', 'paste', 'pastetext', '|',
'visualchars', 'visualblocks', 'nonbreaking', 'blockquote', 'template', '|',
'print', 'preview', 'codesample', 'insertdatetime', 'removeformat', 'jxtdbuttons',
'language',
),
'toolbar2' => array(),
);
Expand Down

0 comments on commit 21c5885

Please sign in to comment.