Skip to content

[css-text] Allow alias for language hyphenation #5270

@sujato

Description

@sujato

The CSS spec provides for hyphenation of text, leaving the choice of language up to the UA:

https://www.w3.org/TR/css-text-4/#hyphenation

Currently Firefox offers the best support, but even they only support fairly small subset of the world's languages.

https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens

The thing is, it is sometimes better to have imperfect hyphenation than none at all. No hyphenation can result in a broken UI and unreadable text, whereas imperfect hyphenation might work fine, or at worst be merely inelegant.

I work with texts in Pali and Sanskrit, which can have very long words formed by compounding. There is no browser support for hyphenation for these, nor is there likely to be. Surely these are not the only languages affected. Here is a typical example, rendered in firefox:

Screenshot from 2020-06-30 09-26-16

It is possible to hack around this by activating hyphens and setting lang='la':

Screenshot from 2020-06-30 09-25-58

This is identical to the result that a proper Pali hyphenation would produce. Note that in tradition Indic orthography, there is no concept of a correct breakpoint; scribes merely wrote to the end of the line and continued on the next line. Thus the traditional practice would agree with the idea that sometimes any breakpoint is better than none.

However, it's obviously not a good idea to deliberately set a false language. Hence my proposal:

Allow the CSS to declare a language alias for hyphenation.

So the text language is unaffected, and the HTML does not change. But the user can declare via CSS something like:

hyphenate-alias-languages: pli, la;

Meaning: "for the purpose of hyphenation, Latin and Pali may be substituted."

Such substitution would apply only if explicit support for that language is missing. So if lang='pli' is set on the HTML, then if one UA has support for Pali hyphens, that is used, if not, it looks for support for Latin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    css-text-4i18n-trackerGroup bringing to attention of Internationalization, or tracked by i18n but not needing response.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions