Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#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
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а' => 'Ср­би­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
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
Re: Hyphenate
I am curious: why CMS should syllable, while a browser is responsible for that? HTML has the lang
attribute, and CSS — hyphens
. 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 ­
, ­
, ­
,
, %AD
, \AD
, \0000AD
forms?
Last edited by Vienuolis (2022-02-23 14:49:04)
Offline
Pages: 1