mundschenk-at / php-typography

A PHP library for improving your web typography.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

French : ne bocomes né

aourednik opened this issue · comments

When using the following settings:

$settings = new PHP_Typography\Settings();
$settings->set_hyphenation( false );
$settings->set_hyphenation_language( 'fr' );
$settings->set_french_punctuation_spacing( true );
$settings->set_smart_quotes_primary( "doubleGuillemets" );
$typo = new PHP_Typography\PHP_Typography();
$content = $typo->process($content,$settings);

the script replaces all ne by né .
My simple workaround

$content = str_replace(""," ne ",$content);

Or am I setting something wrog?

You need to disable the smart diacritics (which default to en-US). It would probably be best if you disable the default settings (which exist mostly for historical reasons) and only explicitly enable the features you want.

// Create settings object without default values.
$settings = PHP_Typography\Settings( false );
// Necessary settings - otherwise the object is not fully functional if the default values are not used.
$settings->set_smart_quotes_primary( "doubleGuillemets" );
$settings->set_smart_quotes_secondary(); // I'm not sure what's used for secondary quotations in French
$settings->set_smart_dashes_style( PHP_Typography\Settings\Dash_Style::INTERNATIONAL );
$settings->set_true_no_break_narrow_space( false );
// Optional settings.
$settings->set_hyphenation( false );
$settings->set_hyphenation_language( 'fr' ); // If hyphenation is off, this will have no effect.
$settings->set_french_punctuation_spacing( true );

The current default setting situation is somewhat US-centric for historical reasons. Unfortunately, removing it introduces a BC break and I missed the chance in 6.0.0.

@aourednik: Have you been able to fix the issue with my explanation?

Looks like this is resolved.