Skip to content

Strings in block.json are not translated from PO file if no other javascript strings are present. #444

Open
@WilliamLeeks

Description

@WilliamLeeks

Bug Report

Describe the current, buggy behavior

Strings in block.json are detected by the make-pot command and added to the POT file. These can eb translated and added to a PO file. However, if block.json is the only non-PHP source of localized strings, running make-json outputs zero files.

Describe how other contributors can replicate this bug

  • Create a simple block as a plugin, including a title and description in the block.json file.
  • Make sure the plugin has a languages folder and its textdomain is loaded using load_plugin_textdomain.
  • Run make-pot in the plugin, to generate a POT file, which will contain entries for the block.json title and description.
  • Translate the title and description (for example using POEdit) and save those translations as PO/MO files in the plugin’s languages folder.
  • Run make-json in the plugin. This will generate zero files, and the translations for the block title/description will not be used.

Describe what you would expect as the correct outcome

I would expect the make-json command to output a JSON file so that the localized strings from block.json can be loaded.

(I am aware it is possible to register a block using localized strings in registerBlockType, but this would mean a duplication of the strings from block.json which does not feel like the intended behaviour.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions