Skip to content
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

mkaz
Copy link
Member

@mkaz 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 added the [Status] In Progress Tracking issues with work in progress label Nov 13, 2018
@mkaz mkaz mentioned this pull request Nov 13, 2018
11 tasks
Using the language translation, allows specifying a different
Google font to load and what the CSS font-family should be.
@mkaz mkaz added Internationalization (i18n) Issues or PRs related to internationalization efforts and removed [Status] In Progress Tracking issues with work in progress labels Nov 15, 2018
Copy link
Contributor

@georgeh georgeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@mkaz mkaz deleted the try/localized-fonts branch November 19, 2018 19:49
@mkaz
Copy link
Member Author

mkaz commented Nov 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internationalization (i18n) Issues or PRs related to internationalization efforts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants