-
Notifications
You must be signed in to change notification settings - Fork 4
Kirby 3 #24
Comments
Yesss! But unfortunately, I dod not find the time for working on that so far. The PHP Typography library also made some great progress since the last release of Kirby-Typography, so a new release would be overdue anyway. |
@fabianmichael, what's the status of this plugin? |
@nilshoerrmann I am currently drowing in work and don’t know, when I can continue working on this plugin. I had big plans in the first place, like a panel view for customizing the plugin. As PHP Typography comes with a myriad of options, I always found it much nicer the way you can edit its settings in WordPress. But I will probably have to stick to the old way of configuring the plugin, even with a revamped version for Kirby 3. In the meantime, I also found out the the most-used feature in my projects is hyphenation. I got a working prototype for a hyphenation plugin, please let me know if you are interested in that instead. |
Thanks for the offer. We are mostly interested in quote, apostrophe and dash handling – hyphenation has not been that important for us so far :) |
Hi @fabianmichael, if you could share with us the hyphenation plugin it would be much appreciated ! |
@tristantbg I’ll try my best. Could take a few days though, as I have to investigate how to store settings for multilanguage-environments. |
I started a little experiment yesterday, if I can get the latest version of PHP Typography running in Kirby 3 and created a simple plugin that takes an array of settings per language and applies them in a field method called @fabianmichael: We never used Kirby 2 and thus we never used your plugin. We don't know how it works internally but our custom plugin does what we need for our projects. Now we don't want to get into your way and don't know how to proceed: we can just keep our plugin private, we can provide you with our plugin code, we can release it as a new plugin for K3. What do you think? This is was the plugin does: <?php
@include_once __DIR__ . '/vendor/autoload.php';
Kirby::plugin('hananils/typography', [
'options' => [
'settings' => [
'*' => [
'style_ampersands' => false,
'style_caps' => false,
'style_initial_quotes' => false,
'style_numbers' => false,
'style_hanging_punctuation' => false,
'initial_quote_tags' => false
],
'de' => [
'smart_quotes_primary' => 'doubleLow9Reversed',
'smart_quotes_secondary' => 'singleLow9Reversed',
'smart_dashes_style' => 'international',
'hyphenation_language' => 'de_DE',
'diacritic_language' => 'de_DE'
],
'fr' => [
'smart_quotes_primary' => 'doubleGuillemetsFrench',
'smart_quotes_secondary' => 'doubleCurled',
'hyphenation_language' => 'fr_FR',
'diacritic_language' => 'fr_FR'
]
]
],
'fieldMethods' => [
'typography' => function ($field) {
$settings = new \PHP_Typography\Settings(true);
$rules = kirby()->option('hananils.typography.settings');
$language = kirby()->language()->code();
// Get global settings
$global = [];
if (isset($rules['*']) && is_array($rules['*'])) {
$global = $rules['*'];
}
// Get local settings
$local = [];
if (!empty($language) && isset($rules[$language]) && is_array($rules[$language])) {
$local = $rules[$language];
}
// Apply settings
$rules = array_merge($global, $local);
foreach ($rules as $key => $value) {
$setting = 'set_' . $key;
if (method_exists($settings, $setting)) {
$settings->$setting($value);
}
}
// Apply typographic styles
$typographer = new \PHP_Typography\PHP_Typography();
$field->value = $typographer->process($field->toString(), $settings);
// Return field for chaning
return $field;
}
]
]); |
Do you plan to make a K3 version of this great plugin ? :)
The text was updated successfully, but these errors were encountered: