-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Blocks: Add i18n support to register_block_type_from_metadata #868
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
Closed
gziolo
wants to merge
5
commits into
WordPress:master
from
gziolo:update/register-block-metadata-i18n
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4331503
Blocks: Add i18n support to register_block_type_from_metadata
gziolo cdc6950
Add unit tests covering i18n support for block.json
gziolo 384f18b
Improve tests for i18n support
gziolo d105534
Use translate_with_gettext_context rather than translate
gziolo 8609bec
Add translations only when textdomain set
gziolo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: \n" | ||
| "POT-Creation-Date: 2015-12-31 16:31+0100\n" | ||
| "PO-Revision-Date: 2021-01-14 18:26+0100\n" | ||
| "Language: pl_PL\n" | ||
| "MIME-Version: 1.0\n" | ||
| "Content-Type: text/plain; charset=UTF-8\n" | ||
| "Content-Transfer-Encoding: 8bit\n" | ||
| "X-Generator: Poedit 2.4.2\n" | ||
| "X-Poedit-Basepath: .\n" | ||
| "Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
| "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;" | ||
| "_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;" | ||
| "esc_html_x:1,2c\n" | ||
| "X-Textdomain-Support: yes\n" | ||
| "Last-Translator: \n" | ||
| "Language-Team: \n" | ||
| "X-Poedit-SearchPath-0: .\n" | ||
|
|
||
| msgctxt "block title" | ||
| msgid "Notice" | ||
| msgstr "Powiadomienie" | ||
|
|
||
| msgctxt "block description" | ||
| msgid "Shows warning, error or success notices…" | ||
| msgstr "Wyświetla ostrzeżenie, błąd lub powiadomienie o sukcesie…" | ||
|
|
||
| msgctxt "block keyword" | ||
| msgid "alert" | ||
| msgstr "ostrzeżenie" | ||
|
|
||
| msgctxt "block keyword" | ||
| msgid "message" | ||
| msgstr "wiadomość" | ||
|
|
||
| msgctxt "block style label" | ||
| msgid "Default" | ||
| msgstr "Domyślny" | ||
|
|
||
| msgctxt "block style label" | ||
| msgid "Other" | ||
| msgstr "Inny" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ocean90, is it good to assume that if there is no
textdomaindefined inblock.jsonthat this block/plugin isn't meant to be translated?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say so, yes. Would core blocks set it to
default? But it actually doesn't seem like it will ever be empty due to the default beingdefault?wordpress-develop/src/wp-includes/blocks.php
Line 238 in b35353a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I thought I removed this line 😅
Yes, I believe we either explicitly set it to
defaultfor core blocks or auto-detect them throughcorenamespace in the block name and auto-applydefaultthis way.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this fallback for now as it's way more complicated for blocks than for plugins where we have:
Plugins fall back to the plugin slug, so we could do the same. What do you think?
The challenges I see:
block.jsoncan be located anywhere, so the parent folder might be not the best way to pickblock.jsonmight be inside the plugin so it would have the textdomain define but the challenge is how to read itblock.jsonmight be inside the theme so it would have the textdomain define but the challenge is how to read itnamefield is constructed fromnamespace/slugso we could use it in a quite reliable way