New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify a different default editor font per locale #11826

Merged
merged 2 commits into from Nov 19, 2018

Conversation

Projects
None yet
2 participants
@mkaz
Member

mkaz commented Nov 13, 2018

Description

Allow translators to specifying a different default font based on the language/locale. The translator can specify a different Google font to load, and what the CSS font-family should be for different locales.

Fixes #9891

Types of changes

Adds two new translation fields to allow language translation to specify a default font.

The first field is Google Font Name and Variants which can be set to off to disable loading an external Google font. The default value is: `Noto Serif:400,400i,700,700i'

The second field is CSS Font Family for Editor Font which is the css font-family name specified in the Google font loaded. The default value is: Noto Serif

This includes the variants because certain fonts may not support italics, for example Noto Sans JP.

The second field could also be used to specify a default system font.

How to Test

Confirm the Editor default text is using the Noto Serif font.

  1. Generate a gutenberg.pot file using makepot.php from core See i18n

  2. Copy gutenberg.pot to gutenberg-es_MX.po

  3. Edit gutenberg-es_MX.po and change the fields, here's the example I used

#: lib/client-assets.php:768
msgctxt "Google Font Name and Variants"
msgid "Noto Serif:400,400i,700,700i"
msgstr "Pacifico:400,700"

#: lib/client-assets.php:1567
msgctxt "CSS Font Family for Editor Font"
msgid "Noto Serif"
msgstr "Pacifico"
  1. Generate the mo file using msgfmt -o gutenberg-es_MX.mo gutenberg-es_MX.po
    If you use Homebrew on OSX, you may need to run brew link gettext --force to add the msgfmt binary.

  2. Go to Settings > General and change your site Language to Espanol de Mexico
    This may require first adding define( 'WPLANG', 'es_MX' ); to your wp-config.php.

  3. Finally confirm the default editor font is changed to Pacifico, which is a distinct script font.

You can obviously test using a different locale and font to match what works best for your language.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@mkaz mkaz referenced this pull request Nov 13, 2018

Closed

Better support for localized fonts #9891

0 of 11 tasks complete
Add ability to specify a different default font
Using the language translation, allows specifying a different
Google font to load and what the CSS font-family should be.

@mkaz mkaz force-pushed the try/localized-fonts branch from 27df5b5 to 0bc1dc2 Nov 14, 2018

@mkaz mkaz added i18n and removed [Status] In Progress labels Nov 15, 2018

@georgeh

Tested and confirmed that I was able to change the editor font using localization tools.

If this becomes a more common thing, we may want to look at making localized CSS part of the build process, but for now this should solve the current issues with minimal overhead.

@mkaz mkaz merged commit 9e464a0 into master Nov 19, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@mkaz mkaz deleted the try/localized-fonts branch Nov 19, 2018

@mkaz

This comment has been minimized.

Member

mkaz commented Nov 19, 2018

grey-rsi pushed a commit to OnTheGoSystems/gutenberg that referenced this pull request Nov 22, 2018

Add ability to specify a different default editor font per locale (Wo…
…rdPress#11826)

* Add ability to specify a different default font

Using the language translation, allows specifying a different
Google font to load and what the CSS font-family should be.

* Switch translation name to not be specific to Noto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment