Repository navigation
Make the default texts of field controls translatable - #110
Merged
dnnsjsk merged 1 commit intoOct 15, 2026
Merged
Conversation
The default texts of textMediaButton, textButton (link and repeater),
textRemove, the reset button of select fields, the alignment buttons and
the code toggle of the WYSIWYG field were assembled at runtime, for
example __( value || 'Add row' ) or __( `Align ${align}` ). No
translation tool can extract such strings, so they stayed in English in
every language. Each variant is now a literal string. Custom texts from
block.json still go through __() in the default text domain as before.
The reset button of select fields had no label: allowReset is a boolean,
so __( allowReset || 'Reset to default' ) returned true, which React does
not render.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #100.
Some default texts of the field controls are assembled at runtime, so no translation tool can extract them and they stay in English even when a translation exists:
__( item?.textMediaButton || 'Open Media Library', … )__( item?.textButton || 'Select Link', … )__( item?.allowReset || 'Reset to default' )__( `Align ${align}` )__( `Switch to ${codeMode ? 'Visual' : 'Code'}` )Each variant is now a literal string. Custom texts from
block.json(textMediaButton,textButton,textRemove) still go through__( text, true )as before, so blocks that set them are unchanged.Two small fixes come with it:
allowResetis a boolean, so__( allowReset || 'Reset to default' )receivedtrueand@wordpress/i18nreturned it unchanged, which React does not render. It now shows "Reset to default".textRemove: trueopened a confirm dialog with the text "true". It now asks the default question.textRemove: falseand string values behave as before.Otherwise the English output is the same. I did not commit rebuilt bundles: a local build of unchanged
mainalready differs from the committed assets on my machine, so please rebuild them as with #100.npm run checkpasses.