Docs · 06
Labels and languages
Every word the panel shows or says can be changed, and it reads in the language of the page.
Labels
The panel’s words are in English by default. The labels attribute changes them, as JSON, and only the ones given change:
<focus-reader
for="article-body"
lang="fr"
labels='{"play": "Lire", "reading": "Lecture", "wordsPerFrame": ["{n} mot par cadre", "{n} mots par cadre"]}'
></focus-reader>
The labels property does the same from a script, over the attribute; null goes back to the attribute’s.
reader.labels = { play: 'Lire', reading: 'Lecture' };
Two things to know about the values:
- a mark like
{wpm}or{n}is filled in with a value; - a pair is
[one, other], picked by the plural rules of the reader’s language.
Labels include what a screen reader hears: the name of each control, and what is said on play, pause and each change of setting. A reader translated only where it shows is half translated.
Lire autrement
Un texte peut se lire de plusieurs façons. Sur le papier, l'œil suit une ligne, saute à la suivante, revient en arrière quand il a perdu le fil, et personne ne le remarque.
Ici, le texte avance seul, au rythme choisi. Les mots déjà lus s'estompent, ceux qui restent attendent, et la ligne en cours reste toujours au même endroit.
With Astro, the integration’s labels option sets them for the whole site. Two of them are the component’s own: open, the text of its button, and noScript, the line a reader in the page shows without JavaScript.
Languages
A reader reads in the language of its lang, or of the nearest lang above it, else English. The language decides three things:
- how numbers are written (the rate, the words read);
- which of a pair of labels is used, by its plural rules;
- how a text written without spaces is cut into words.
Words are cut at spaces. A run in a script written without them (Chinese, Japanese, Thai, Lao, Khmer, Burmese) is cut by Intl.Segmenter for that language, its punctuation kept with the word before it and an opening bracket or quote with the word after.
<focus-reader lang="ja">
<template>
<p>吾輩は猫である。名前はまだ無い。</p>
</template>
</focus-reader>
Every label
The 80 keys and their English defaults, read from LABELS when this page is built.
| Key | Default |
|---|---|
name | Focus reader |
settings | Settings |
view | View |
sequence | Sequence |
flow | Flow |
speed | Speed |
slower | Slower |
faster | Faster |
words | Words |
fewerWords | Fewer words per frame |
moreWords | More words per frame |
size | Size |
smaller | Smaller text |
larger | Larger text |
align | Align |
alignLeft | Left |
alignCenter | Centre |
alignPivot | Pivot |
underline | Underline |
underlineLabel | Underline the words being read |
highlight | Highlight |
highlightLabel | Dim the words read and the words ahead |
on | On |
off | Off |
band | Reading band. Space to play or pause, left and right arrows to move by frame, up and down arrows for speed, scroll to move by frame. |
flowArea | Reading flow. Space to play or pause, left and right arrows to move by frame, up and down arrows for speed. |
rate | Rate |
wpm | wpm |
read | Read |
remaining | Left |
minutes | min |
hours | h |
progress | Progress |
progressLabel | Keep the figures and the progress bar while it plays |
position | Position in the text |
positionValue | Word {word} of {total}, {left} {unit} left |
play | Play |
reading | Reading |
again | Read again |
keySpace | Space |
keyPlay | play |
keyArrows | ← → |
keyFrame | frame |
keyScroll | Scroll |
keyScrollSequence | frame |
keyScrollFlow | text |
keyUpDown | ↑ ↓ |
keySpeed | speed |
keyEscape | Esc |
keyClose | close |
touchKeys | Tap to play or pause, swipe for a word |
barsHint | Swipe up to hide the browser bars |
fullScreen | Full screen |
fullScreenLabel | Open the reader full screen |
close | Close |
closeLabel | Close the reader |
startKeys | Press Space or click the band to start. |
startTouch | Tap the band to start. |
playing | Playing at {wpm} words per minute |
paused | Paused, word {word} of {total} |
end | End of the text |
wpmSaid | {wpm} words per minute |
wordsPerFrame | {n} word per frame {n} words per frame |
wordsAtATime | {n} word at a time {n} words at a time |
paragraph | A paragraph at a time |
sizeSaid | Size {size} |
viewSaid | {view} view |
viewLabel | View: {view}. Change |
alignSaid | Aligned {align} |
alignLabel | Alignment: {align}. Change |
underlineOn | Underline on |
underlineOff | Underline off |
highlightOn | Highlight on |
highlightOff | Highlight off, the whole text in ink |
progressOn | Progress shown while it plays |
progressOff | Progress hidden while it plays |
settingsOn | Settings shown |
settingsOff | Settings hidden |
open | Focus reader |
noScript | The focus reader needs JavaScript. |