Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.1] language of parts [a11y] #30939

Closed
wants to merge 18 commits into from
Closed

Conversation

brianteeman
Copy link
Contributor

@brianteeman brianteeman commented Oct 6, 2020

This is a plugin for TinyMCE 5 that allows users to specify what language their text is written in. As TinyMCE does not currently provide a plugin for language of parts this is an implementation of https://github.com/edx/tinymce-language-selector/.

The plugin 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..."

parts

The only valid comments are on the implementation of the plugin. Comments about the plugin itself should be addressed upstream at https://github.com/edx/tinymce-language-selector/

[ 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 ]

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

Testing

Dont forget to do a full npm ci

Todo - Help Wanted

In the build scripts

  1. Remove the empty folder media\vendor\tinymce-language-selector\
  2. To be compliant with the license node_modules@edx\tinymce-language-selector\LICENSE needs to be copied to the final folder
    Thank to @dgrammatiko for the work so far on those scripts

@joomla-cms-bot joomla-cms-bot added NPM Resource Changed This Pull Request can't be tested by Patchtester PR-4.0-dev labels Oct 6, 2020
@brianteeman
Copy link
Contributor Author

Any help on that part @dgrammatiko will be greatly appreciated

@dgrammatiko
Copy link
Contributor

Any help on that part @dgrammatiko will be greatly appreciated

I'm working on it. Unfortunately the build tools are not in great shape...

@brianteeman
Copy link
Contributor Author

ah - ok. I did spend a few hours trying but that was more a trial by error than actually knowing what I was doing

@dgrammatiko
Copy link
Contributor

@brianteeman check brianteeman#116

I will have to redo the JS part of the build tools but that should be ok for this PR

@brianteeman
Copy link
Contributor Author

Thank @dgrammatiko reviewing it and will work on the pr in the morning. really appreciate the assistance

@brianteeman
Copy link
Contributor Author

brianteeman commented Oct 7, 2020

@dgrammatiko almost but not quite. The following needs to happen

1. Remove export { BROWSER_DEFAULT, languages }; from the final plgin.js
2. Remove the empty folder media\vendor\tinymce-language-selector\
3. To be compliant with the license node_modules\@edx\tinymce-language-selector\LICENSE needs to be copied to the final folder

I really did try and work out how to do all of this and I learnt a lot but not enough to resolve this

@brianteeman brianteeman marked this pull request as ready for review October 12, 2020 21:20
@brianteeman brianteeman changed the title [4.0] language of parts [4.0] language of parts [a11y] Oct 12, 2020
@adj9
Copy link

adj9 commented Oct 20, 2020

I tried PR with a complete installation of Joomla! and the choice of languages in TinyMCE is not yet present.

@brianteeman
Copy link
Contributor Author

@adj9 please check in the plugin that its enabled for the toolbar you are using

@adj9
Copy link

adj9 commented Oct 20, 2020

@brianteeman
You can tell me the name of the created plugin. In "Edit - TinyMCE" everything is enabled except "Use Joomla Text Filter". Thanks

@carcam
Copy link

carcam commented Oct 20, 2020

@brianteeman I tried to test this on Saturday and I also couldn't. The tiny plugin is not being correctly moved on npm ci (although in the log you can see some action is taken)

I thought it was still a WiP and that's why I didn't comment earlier but reading your reply I guess this should work.

Maybe @dgrammatiko can provide some hint on what might be happening?

@brianteeman
Copy link
Contributor Author

brianteeman commented Oct 20, 2020

I have retested and found a few errors. Please retest by running npm ci

At this point you should have folders as in the screenshots below

node_modules/

image

media/

image

Check the plugin

image

Check Set 0 and click use advanced preset

image

Check editor in article

image

@carcam
Copy link

carcam commented Oct 21, 2020

@brianteeman thank you very much for this clear explanation!! I can see the node_modules folder (I could also on Saturday) ✅.

Now I can also see the folder in "media/plg_editors_tinymce/js/plugins/tinymce-language-selector" which I was not able to see on Saturday (I was not looking deeper enought in the tree I guess) ✅

folder listing of the tinymce-language-selector folder in Joomla

But the "Language" button does not appear in the plugin editor:

Captura de pantalla 2020-10-21 a las 5 38 18

What am I missing? After npm ci should I do anything else?

Thank you very much!!

@infograf768
Copy link
Member

infograf768 commented Oct 21, 2020

It's working as intended here.

Two drawbacks:

  1. no possibility to parameter the plugin (display)
  2. no possibility to add languages Joomla proposes (prs, ckb, sy, srp, maybe others)

Concerning 1. It would be great to be able to choose the display between English (name) and language nativeName in the js in order to get if desired:

Screen Shot 2020-10-21 at 09 33 55

I modified the es6.js but it is always retrieved from https://registry.npmjs.org/@edx/tinymce-language-selector/-/tinymce-language-selector-1.1.0.tgz and evidently changes are lost when running npm ci.

One question: what does displaying a span with the lang tag gives as benefit to a11y? Would a screenreader finding the fa span be useful to tell the user that part is in Persian even if, by luck, it can read the content with a Persian accent?

@infograf768
Copy link
Member

@carcam
Your test site is not current as the tabs have been corrected.
But nevertheless, your screenshot displays the existing toolbar for Set0

Look above the tabs. There you will find the Language button.
Drag and drop that button to the sets to use it.
Screen Shot 2020-10-21 at 10 14 14

@brianteeman
Copy link
Contributor Author

@carcam Did you click on the Use Advanced Preset?

@infograf768
See original post

The only valid comments are on the implementation of the plugin. Comments about the plugin itself should be addressed upstream at https://github.com/edx/tinymce-language-selector/

Re the usefulness of the plugin. The accent thing is just an example. It is a requirement of WCAG AA that the language can be programmatically determined. It is not for us to question the WCAG

@brianteeman brianteeman reopened this Oct 21, 2020
@dgrammatiko
Copy link
Contributor

no possibility to add languages Joomla proposes (prs, ckb, sy, srp, maybe others)

That’s doable. If someone comes up with the field in the backend I can patch the js

@Quy
Copy link
Contributor

Quy commented Nov 15, 2020

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/30939.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Nov 15, 2020
@brianteeman
Copy link
Contributor Author

Please remove the rtc. There are several outstanding todo

@Quy Quy removed the RTC This Pull Request is Ready To Commit label Nov 15, 2020
@Quy Quy added the Updates Requested Indicates that this pull request needs an update from the author and should not be tested. label Dec 4, 2020
@wilsonge
Copy link
Contributor

wilsonge commented Jan 3, 2021

@brianteeman is the todos in the PR description still current? Or other things to be done?

@wilsonge
Copy link
Contributor

wilsonge commented Jan 3, 2021

OK I think this brianteeman#119 is what you were after. But let me know and can tweak further. I'm not an expert at these build scripts so 🤷‍♂️

@brianteeman
Copy link
Contributor Author

Thanks @wilsonge I will check it shortly. However at this time I think this will need to be retargeted for 4.1

@wilsonge
Copy link
Contributor

wilsonge commented Jan 3, 2021

Agreed

@brianteeman brianteeman changed the title [4.0] language of parts [a11y] [4.1] language of parts [a11y] Jan 3, 2021
@Quy Quy added this to the Joomla 4.1 milestone Jan 3, 2021
@Quy Quy added PR-4.1-dev and removed PR-4.0-dev labels Jan 3, 2021
@infograf768
Copy link
Member

infograf768 commented Jan 4, 2021

Some tests with the new code:
Still no reply from openedx/tinymce-language-selector#13

That is: #30939 (comment)
I have'nt seen anything new in this patch to cope with it.

Also no reply here to #30939 (comment) concerning the translation of the term Browser Default in the dropdown as well as Current Language: in the pop-up.

const languages = {
  // not a language, used to represent absence of a language defaulting to browser language
  BROWSER_DEFAULT: {
    name: 'Browser default',
    nativeName: 'Browser default'
  },
editor.windowManager.open({
      title: 'Language plugin',
      body: {
        type: 'panel',
        items: [{
          type: 'htmlpanel',
          html: `<div>Current language: ${languages[currentLang].nativeName}</div>`
        }, {
          type: 'selectbox',
          name: 'language',
          label: 'Language',
          items: Object.keys(languages).map(lang => ({
            value: lang,
            text: languages[lang].nativeName
          }))
        }]
      },

No mention either of a necessary update to the tinyMCE lang js updates in
/build/media_source/vendor/tinymce/langs/ all js files for Browser default language and Language Plugin added by this patch.

For French it would need adding to fr.es5.js
"Browser default language": "Langue par d\u00e9faut du navigateur",
"Language Plugin": "Plugin de langue"

to get
Screen Shot 2021-01-04 at 11 02 03

Bug

If I have'nt done anything wrong:

When admin is French Language and selecting a lang other than "Browser Default" in the pop-up, I get :
Uncaught TypeError: button is undefined plugin.js:813:7

line is:

    if (!lang || lang === BROWSER_DEFAULT) {
      button.innerText = 'Browser default language';
    } else {
      button.innerText = languages[lang].nativeName; // Line 813
    }

The pop-up does not close although the span is added to the text, for example <span lang="af">Joomla</span>

I also sometimes get the error below.

When admin is in en-GB, and I forget to highlight a term, I get:

Failed to find and set button ID in TinyMceLanguageSelectorPlugin after 3 attempts. plugin.js:921:15

although, this time the language selected does appear in the editor's bar.

@brianteeman
Copy link
Contributor Author

This is on hold until after 4.0. No point working on something with a 4.1 target at this time

@wilsonge wilsonge marked this pull request as draft January 4, 2021 11:56
@wilsonge
Copy link
Contributor

wilsonge commented Jan 4, 2021

Moved this to draft so it's clear

@infograf768
Copy link
Member

Moved this to draft so it's clear

Good decision. My tests just demonstrated that there are much more TODOs than stated in the description.

@Quy Quy added the a11y Accessibility label Jan 23, 2021
@brianteeman brianteeman closed this Feb 3, 2021
@brianteeman
Copy link
Contributor Author

this will be re-opened after 4.0 is released

@brianteeman brianteeman reopened this Sep 6, 2021
@brianteeman
Copy link
Contributor Author

This PR is now closed and will be created using new core tinymce functionality

@brianteeman brianteeman deleted the sk-tinymce branch September 19, 2021 18:56
brianteeman added a commit to brianteeman/joomla-cms that referenced this pull request Sep 19, 2021
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
@brianteeman
Copy link
Contributor Author

brianteeman commented Sep 19, 2021

Replaced with #35607

bembelimen added a commit that referenced this pull request Nov 21, 2021
* [4.1] Language of Parts [a11y]

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 #35605 which at the time of this PR has not been merged into 4.1dev

This is a replacement PR of #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

* css

* xml

* lint

* array

* language strings

* Update plugins/editors/tinymce/tinymce.php

Co-authored-by: Quy <[email protected]>

Co-authored-by: Quy <[email protected]>
Co-authored-by: Benjamin Trenkle <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y Accessibility NPM Resource Changed This Pull Request can't be tested by Patchtester Updates Requested Indicates that this pull request needs an update from the author and should not be tested.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants