Skip to content

Extract translatable strings from theme.json files #224

@jorgefilipecosta

Description

@jorgefilipecosta

Feature Request

Describe your use case and the problem you are facing

For supporting the next generation of themes, we need to extract strings from theme.json files.

Describe the solution you'd like

wp i18n make-pot should parse theme.json files and extract all strings it finds with the additional context.

Sample file:

{
	"global": {
		"presets": {
			"color": [
				{
					"slug": "blue",
					"value": "#00f",
					"name": "Red"
				}
			],
			"font-size": [
				{
					"slug": "small",
					"value": 13,
					"name": "Small"
				}
			],
			"font-family": [
				{
					"value": "-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif",
					"slug": "system",
					"name": "System"
				}
			],
			"gradient": [
				{
					"slug": "blush-bordeaux",
					"value": "linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%)",
					"name": "Another gradient"
				}
			]
		}
	},
	"core/paragraph": {
		"presets": {
			"color": [
				{
					"slug": "red",
					"value": "#f00",
					"name": "Red"
				}
			],
			"font-size": [
				{
					"slug": "small",
					"value": 13,
					"name": "Small"
				}
			],
			"font-family": [
				{
					"value": "-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif",
					"slug": "system",
					"name": "System"
				}
			],
			"gradient": [
				{
					"slug": "blush-bordeaux",
					"value": "linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%)",
					"name": "Simple gradient"
				}
			]
		}
	}
}

In all these cases "name" should be translatable.
For now, these files are named experimental-theme.json (future theme.json) on WordPress themes, and experimental-default-theme.json (future default-theme.json) for the core own default file.

It is very related to the work done for block.json #210.

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