WordPress / wporg-parent-2021

17 stars 10 forks source link

Rosetta: Enable locale-specific customizations to theme.json settings. #120

Closed ryelle closed 7 months ago

ryelle commented 7 months ago

Add a method for overriding the default parent theme settings for rosetta sites. This will allow polyglots teams to provide, for example, preferred font sizes, which they or a meta dev can then code into the get_locale_customizations function using a theme.json format, so that any values defined in settings can be adjusted. While the entire object can be updated (so that locales can also control the responsive sizes and line heights), some things like colors will likely not be allowed to change.

This PR works in tandem with https://github.com/WordPress/wporg-main-2022/pull/380, which adds a new CSS file for specific rosetta site overrides.

In practice, I see this working like so:

If we end up with many customization requests, we could look at providing a UI for polyglots teams to manage this themselves, but I'd like to start here first.

Review question: Is get_locale() the best thing to switch on, or is there a better, rosetta-specific function I should use?

See https://github.com/WordPress/wporg-main-2022/issues/266, Fixes https://github.com/WordPress/wporg-main-2022/issues/306

Screenshots

I took a number of screenshots (with an automated script), you can look through the whole batch here.

Homepage

In Catalan (and fr, it, ro), the heading CTA font is smaller (first two sections, community section, get started). In Japanese, the heading CTA and heading-2 fonts are smaller (all other headings).

Locale Before After
English (UK) home-en-gb-before home-en-gb-after
Catalan home-ca-before home-ca-after
Japanese home-ja-before home-ja-after

Download page

Here, you can see the heading-2 size difference in the last two sections.

Before After
download-ja-before download-ja-after

How to test the changes in this Pull Request:

You can test localized sites by following the instructions on wporg-main-2022.

I also tested this on my sandbox with the top completed languages for wporg.

After that, just clicking around pages and making sure they look okay. What I used:

t-hamano commented 7 months ago

Thanks for the PR! There is one thing that concerns me about the Japanese site.

image

This line break is very strange to Japanese people.

For example, imagine the following displayed on an English site.

image

What we expect is to be displayed as follows.

image

We have also not inserted any special line break tags for this text.

image

I would also like to find out the cause, but do you know why this problem occurs?

ryelle commented 7 months ago

We have also not inserted any special line break tags for this text.

It looks like there are linebreaks in the strings, <span>WordPress:</span><br />発信を<strong>すべての</strong>人の手に

https://translate.wordpress.org/projects/meta/wordpress-org/ja/default/?filters%5Bterm%5D=%2Fsrc%2Frandom-heading%2Findex.php&filters%5Bterm_scope%5D=scope_any&filters%5Bstatus%5D=current_or_waiting_or_fuzzy_or_untranslated&filters%5Buser_login%5D=&filter=Apply+Filters&sort%5Bby%5D=priority&sort%5Bhow%5D=desc

If I add CSS to make the bold text not wrap, that helps on the "Publish your passion" string. But I think the business string is still breaking in a bad place. If you remove those linebreaks though, I think the combination of both will fix it. How does the second column here look to you?

With linebreak No linebreak
Passion with-br-passion no-br-passion
Business with-br-business no-br-business
Freedom with-br-freedom no-br-freedom
t-hamano commented 7 months ago

Thank you for your detailed testing.

It looks like there are linebreaks in the strings, <span>WordPress:</span><br />発信を<strong>すべての</strong>人の手に

Sorry, I missed one br tag 😅😅

How does the second column here look to you?

This depends on the variation being displayed, but in general, it looks more natural without a linebreak.

This PR simply changes the font size according to the locale, so this problem might be fixed by adding appropriate line breaks on GlotPress.

We will be able to find out the cause of this problem and fix it in advance by enabling preview mode. If a line break alone doesn't solve the problem, we might submit a PR adding some styles as a follow-up.

Sorry for confusing you 🙇

ryelle commented 7 months ago

This PR simply changes the font size according to the locale, so this problem might be fixed by adding appropriate line breaks on GlotPress.

Right, the line breaks need to be changed on GlotPress.

If a line break alone doesn't solve the problem, we might submit a PR adding some styles as a follow-up.

That would be great.

Sorry for confusing you 🙇

No confusion here — I just want to help you get a site that looks good :)

I'm going to merge this PR for the font size updates, and we can continue the conversation on https://github.com/WordPress/wporg-main-2022/issues/266