nystudio107 / craft-typogrify

Typogrify prettifies your web typography by preventing ugly quotes and 'widows' and more

Home Page:https://nystudio107.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Configure typogrify plugin based on site language

lexislav opened this issue · comments

In multi-language/site environment setting for individual sites would be very usefull

Different settings for languages would be super usefull - for example different quotes settings for french, english, slovak… etc.

I have tried, but config typogrify.php doesn't seem to support

'*' => [ all sites/languages],
'de' => [ settings for german ]
'hu' => [ settings for hungary]

or

'siteHandle' => [settings for site]

actually the config doesnt seem to suppport even

'domain.com/hu' => [settings for the site]

that would be quite useful.

Only settings from '*' seems to be applied.

The config file is a standard Craft CMS config file, which allows for multi-environment configuration.

However, since it's just PHP, you can do whatever you want in there... so if you wrote something that looked at the current site, and used that to determine what config to return, it'd absolutely work!

I had the same task and solved it by simply using the advanced config option described in the docs.

https://nystudio107.com/docs/typogrify/#advanced-usage

Example:

{% if currentSite.language == 'de-DE' %}
    {% do phpTypographySettings.set_smart_quotes_primary('doubleLow9Reversed') %}
    {% do phpTypographySettings.set_smart_quotes_secondary('singleLow9Reversed') %}
{% else %}
    {% do phpTypographySettings.set_smart_quotes_primary('singleCurled') %}
    {% do phpTypographySettings.set_smart_quotes_secondary('doubleCurled') %}
{% endif %}

Did a simple if else endif in my template and changed the couple of settings needs. Put it in to my base layout file and done.