Project

General

Profile

Actions

Task #104831

closed

Epic #103034: Unified Settings API

Allow translations of site settings labels and description

Added by Benjamin Franzke about 1 month ago. Updated 5 days ago.

Status:
Closed
Priority:
Should have
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.


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Task #104840: Auto-register set labels from labels.xlfClosedBenjamin Franzke2024-09-06

Actions
Related to TYPO3 Core - Task #104867: Add integrity check for set labelsClosedBenjamin Franzke2024-09-09

Actions
Actions #1

Updated by Benjamin Franzke about 1 month 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
Actions #2

Updated by Gerrit Code Review about 1 month 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

Actions #3

Updated by Gerrit Code Review about 1 month 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

Actions #4

Updated by Benjamin Franzke about 1 month ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #5

Updated by Benjamin Franzke about 1 month ago

  • Related to Task #104840: Auto-register set labels from labels.xlf added
Actions #6

Updated by Benjamin Franzke about 1 month ago

  • Related to Task #104867: Add integrity check for set labels added
Actions #7

Updated by Benni Mack 5 days ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF