question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: Allow setting document language for hyphenation

See original GitHub issue

It would be nice if Homebrewery allowed setting document language other than English. All it would do would be placing a lang attribute on the appropriate HTML element.

The main use case is hyphenation, which requires the correct HTML lang attribute to be set. Specifically: I would like to typeset documents in English and Russian with hyphenation. While I can set hyphens: auto in CSS, currently neither language works because there is no lang attribute in the document, so the browser doesn’t know which language to hyphenate for.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ericscheidcommented, May 3, 2021

The appropriate element would likely be the <div class="pages">, which wraps all the individual pages.

In the brew properties panel we could put a simple text field with default value of en. We’d need to allow for more than 2 characters as valid lang attribute values includes “zh-Hans”, “zh-Hant”, “ru-Cyrl-BY” etc.

Hmm … the max length can be figured from https://www.ietf.org/rfc/bcp/bcp47.txt … it’s late, I’m tired, and I left my ABNF decoder ring at home.

0reactions
Gazook89commented, Oct 23, 2022

So I have the above set up except instead of hardcoding both the code and the ‘name’ it only needs the code, and the display name is automatically given in that language. Same end result, but with less work.

I am working on setting the regexp pattern now. I see your basic pattern [a-z]{2,3}(-.*)? and that seems good enough to prevent entering ‘English’ or similar names…is that ‘good enough’ for our purposes? Or should we use a more robust pattern as given here:

^(((en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((([A-Za-z]{2,3}(-([A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-([A-Za-z]{4}))?(-([A-Za-z]{2}|[0-9]{3}))?(-([A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-([0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(x(-[A-Za-z0-9]{1,8})+))?)|(x(-[A-Za-z0-9]{1,8})+))$

Note, on initial testing with this, it still allows for “English” as a valid entry, so i’m not sure if this regexp needs tweaking or if that is desirable.

This also only is a regexp pattern…it would allow for invalid values as long as they fit the pattern. So instead, we could use a library like IETF Language Tags which would provide methods for checking against the actual list of language codes.

I’m just not sure how deep we want to go? If we settle for just a limited list, it isn’t hard to add languages later…it would just be adding the correct code to an array without even worrying about the displayName, since that is automatically taken care of.

I’ll upload my branch today. And for now i’m just going to use your pattern.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Native language hyphenation - InDesign UserVoice
Hi John, maybe this could help. In my german Indesign Version under Preferences > Hyphenation i can choose "Duden".
Read more >
Control hyphenation - Microsoft Support
Hyphenate part of a document manually · Select the text that you want to hyphenate. · On the Tools menu, click Hyphenation. ·...
Read more >
Working with Hyphenation in C#|Aspose.Words for .NET
Since different languages use different norms and rules for word hyphenation, the optimal solution for correct hyphenation is to use special dictionaries.
Read more >
optional fields in setup | Hyphenopoly - GitHub Pages
To hyphenate a text, its language needs to be known to the system (be it native CSS hyphenation or Hyphenopoly.js). Thus the language...
Read more >
hyphens | CSS-Tricks
Conditional hyphenation characters inside a word, if present, take priority over automatic resources when determining hyphenation points within ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found