Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-03-30 17:36:52

dorijan
New Member
From: Belgrade, SRB
Registered: 2021-01-04
Posts: 5

Hyphenate

Hyphenation patterns for many languages are widely available.
I have them for Serbian Cyrillic and Latin.
Browser support and CSS rules work for several well-known languages.

It would be useful to have hyphenation plugin which would accomodate other languages.
One plugin-multilingual support.
Thus a newspaper and book-alike websites could be created in many languages.

Unfortunately I do not have technical skills (at least not yet) to make one and pat_hyphenate is not maintained any more (Thank you Patrick for fast response).

Is it doable?

Regards D.B.


Thrive on simplicity

Offline

#2 2021-05-25 10:07:10

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

Re: Hyphenate

Hi Dorijan,

it’s both easy and difficult. To test the easy part, just save the following in textpattern/plugins/abc_hyphen.php file:

<?php
$plugin['name'] = 'abc_hyphen';
$plugin['version'] = '0.1';
$plugin['author'] = 'Textpattern Community';
$plugin['author_uri'] = 'https://github.com/textpattern';
$plugin['description'] = 'Hard-coded hyphenation';
$plugin['order'] = '5';

if (txpinterface == 'admin')
  register_callback('abc_hyphen', 'textfilter', 'filter', 0);

function abc_hyphen($event, $step, &$rs) {
  $rs = strtr($rs, array('Србиjа' => 'Ср&shy;би&shy;jа'));
}

Now each occurrence of ‘Србиjа’ in Body or Excerpt should be hyphenated on article save in their _html versions used for the output (check the preview). You must, of course, import the whole hyphenation array from somewhere (file, …), but you get the idea.

More difficult parts:

  • take the article language into account (well, rather easy);
  • make the hyphenation case insensitive;
  • avoid inappropriate substrings hyphenation;
  • avoid hyphenating eventual tag names like e.g. <object> and attributes.

But feel free to experiment.

Offline

#3 2021-05-26 07:22:18

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

Re: Hyphenate

A third-party (phpSyllable) based plugin is available now (txp 4.8+ only). It will append a ‘Hyphenate’ textfilter option to Body and Excerpt.

The hyphenation will be done using the public language patterns (if available). About 75 languages are included, you can remove the unused ones and download them again when necessary.

Edit: hmm, working on my localhost, but not on the demo site. Investigating… done!

Offline

#4 2022-02-23 08:44:24

dorijan
New Member
From: Belgrade, SRB
Registered: 2021-01-04
Posts: 5

Re: Hyphenate

etc wrote #330261:

A third-party (phpSyllable) based plugin is available now (txp 4.8+ only). It will append a ‘Hyphenate’ textfilter option to Body and Excerpt

Thank you very much. I’m working on my PHP as it is obviously a necessity. Looking forward to this. Will report when the time comes. All the best.


Thrive on simplicity

Offline

#5 2022-02-23 12:14:05

Vienuolis
Member
From: Vilnius, Lithuania
Registered: 2009-06-14
Posts: 310
Website GitHub GitLab Mastodon Twitter

Re: Hyphenate

I am curious: why CMS should syllable, while a browser is responsible for that? HTML has the lang attribute, and CSShyphens. Please check for example, are words syllabicated for you on this Lithuanian website with some cites in another languages: az.on.lt/dvibalsis-uo — with only hyphens:auto in a stylesheet.

Not all browsers still support syllabling yet: caniuse.com/css-hyphens.

Will Textpattern recognize chpped words in its search query? And Googlebot, Yandex, Bing, other crawlers and indexers? In all the &shy;, &#173;, &#xad;, ­­, %AD, \AD, \0000AD forms?

Last edited by Vienuolis (2022-02-23 14:49:04)

Offline

Board footer

Powered by FluxBB