Actions
Task #104831
closedEpic #103034: Unified Settings API
Allow translations of site settings labels and description
Status:
Closed
Priority:
Should have
Assignee:
Category:
Site Handling, Site Sets & Routing
Target version:
Start date:
2024-09-05
Due date:
% Done:
100%
Estimated time:
TYPO3 Version:
13
PHP Version:
Tags:
Complexity:
Sprint Focus:
Description
Definitions from settings.definition.yaml should be translatable, core needs to provide .xlf files to be translatable on crowdin.
Updated by Benjamin Franzke 3 months ago
Script to migrate an existing settings.definition.yaml to a xlf file:
create-xlf.php
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Symfony\Component\Yaml\Yaml;
$filename = $_SERVER['argv'][1];
$product = $_SERVER['argv'][2];
$destination = $_SERVER['argv'][3];
$xml = new DOMDocument('1.0', 'UTF-8');
$xml->formatOutput = true;
$xliff = $xml->createElement('xliff');
$xliff->setAttribute('version', '1.2');
$xliff->setAttribute('xmlns', 'urn:oasis:names:tc:xliff:document:1.2');
$file = $xml->createElement('file');
$file->setAttribute('source-language', 'en');
$file->setAttribute('datatype', 'plaintext');
$file->setAttribute('original', 'EXT:' . $product . '/Resources/Private/Language/' . $destination);
$file->setAttribute('date', strftime('%Y-%m-%dT%H:00:00Z'));
$file->setAttribute('product-name', $product);
$header = $xml->createElement('header');
$file->appendChild($header);
$body = $xml->createElement('body');
$data = Yaml::parseFile($filename);
foreach ($data['settings'] as $key => $setting) {
$index = 'settings.' . $key;
$unit = $xml->createElement('trans-unit');
$unit->setAttribute('id', $index);
$unit->setAttribute('resname', $index);
$source = $xml->createElement('source');
$source->textContent = $setting['label'];
$unit->appendChild($source);
$body->appendChild($unit);
if ($setting['description'] ?? '') {
$index = 'settings.description.' . $key;
$unit = $xml->createElement('trans-unit');
$unit->setAttribute('id', $index);
$unit->setAttribute('resname', $index);
$source = $xml->createElement('source');
$source->textContent = $setting['description'];
$unit->appendChild($source);
$body->appendChild($unit);
}
}
$file->appendChild($body);
$xliff->appendChild($file);
$xml->appendChild($xliff);
$resultingFile = 'typo3/sysext/' . $product . '/Resources/Private/Language/' . $destination;
file_put_contents($resultingFile, $xml->saveXML());
php create-xlf.php typo3/sysext/fluid_styled_content/Configuration/Sets/FluidStyledContent/settings.definitions.yaml fluid_styled_content locallang_set.xlf
sed -i -e "/^[ ]*label:/d" -e "/^[ ]*description:/d" typo3/sysext/fluid_styled_content/Configuration/Sets/FluidStyledContent/settings.definitions.yaml
Updated by Gerrit Code Review 3 months ago
- Status changed from New to Under Review
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/85869
Updated by Gerrit Code Review 3 months ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/85869
Updated by Benjamin Franzke 3 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 7766e194b4de143bab140c932c45462565830ac9.
Updated by Benjamin Franzke 3 months ago
- Related to Task #104840: Auto-register set labels from labels.xlf added
Updated by Benjamin Franzke 2 months ago
- Related to Task #104867: Add integrity check for set labels added
Actions