Skip to content

IBX-12091: Added TypeScript translation extraction support - #1967

Open
mikadamczyk wants to merge 7 commits into
6.0from
feature/IBX-12091-typescript-translation-extraction
Open

IBX-12091: Added TypeScript translation extraction support#1967
mikadamczyk wants to merge 7 commits into
6.0from
feature/IBX-12091-typescript-translation-extraction

Conversation

@mikadamczyk

@mikadamczyk mikadamczyk commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
🎫 Issue IBX-12091

Description:

This PR adds TypeScript translation extraction support for Translator.trans() and Translator.transChoice() calls, including translation descriptions from @Desc comments. The extractor uses a persistent Node.js process with runtime validation, response timeouts, error handling, and automatic restart after failures. The implementation separates the JMS visitor from process management and installs frontend dependencies in the backend CI job so the tests can run correctly.

For QA:

Documentation:

@mikadamczyk
mikadamczyk force-pushed the feature/IBX-12091-typescript-translation-extraction branch from 5198656 to 8b44786 Compare July 16, 2026 08:51
@mikadamczyk
mikadamczyk marked this pull request as ready for review July 20, 2026 10:19
Comment thread .github/workflows/backend-ci.yaml Outdated
Comment thread src/lib/Translation/Extractor/typescript_translation_extractor.mjs Outdated
Comment thread src/lib/Translation/Extractor/typescript_translation_extractor.mjs Outdated
Comment thread src/lib/Translation/Extractor/typescript_translation_extractor.mjs
Comment thread src/lib/Translation/Extractor/typescript_translation_extractor.mjs
Comment thread src/lib/Translation/Extractor/typescript_translation_extractor.mjs Outdated
@albozek
albozek requested a review from GrabowskiM July 20, 2026 13:31
Comment thread src/lib/Translation/Extractor/typescript_translation_extractor.mjs
@albozek
albozek force-pushed the feature/IBX-12091-typescript-translation-extraction branch from 26d6cc2 to 8b9bbb0 Compare July 20, 2026 13:49
@mikadamczyk
mikadamczyk requested a review from a team July 21, 2026 11:40
@ibexa-workflow-automation-1
ibexa-workflow-automation-1 Bot requested review from Steveb-p, ViniTou, alongosz, barw4, bnowak, ciastektk, konradoboza, tbialcz and wiewiurdp and removed request for a team July 21, 2026 11:40

@konradoboza konradoboza left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

Comment thread src/lib/Translation/Extractor/TypeScriptExtractorClient.php

final class TypeScriptExtractorClient
{
private const DEFAULT_RESPONSE_TIMEOUT_SECONDS = 30.0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private const DEFAULT_RESPONSE_TIMEOUT_SECONDS = 30.0;
private const float DEFAULT_RESPONSE_TIMEOUT_SECONDS = 30.0;

Comment thread src/lib/Translation/Extractor/TypeScriptExtractorClient.php
Comment thread src/lib/Translation/Extractor/TypeScriptFileVisitor.php
* @param array<mixed> $ast
*/
public function visitPhpFile(SplFileInfo $file, MessageCatalogue $catalogue, array $ast): void
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we provide a comment why it is empty? 😉 Same goes for the Twig below.


public function testServeModeProcessesMultipleFilesSequentiallyAndSurvivesPerFileErrors(): void
{
$goodFile = tempnam(sys_get_temp_dir(), 'ts_extractor_') . '.ts';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tempnam() creates the file immediately. Appending .ts only modifies the returned path, so file_put_contents() creates a second file and the original temporary file is never removed. Could we rename the file instead, as done in testExtractsExpectedMessages()? The same applies to the other tempnam(...).'.ts' occurrences.

Comment thread src/lib/Translation/Extractor/TypeScriptFileVisitor.php Outdated
Comment thread src/lib/Translation/Extractor/TypeScriptFileVisitor.php Outdated

@alongosz alongosz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SonarQube analysis is relevant to the changes and should be addressed. It doesn't mean it's correct. In some cases (maybe even most) it's false-positive, but then it needs to be marked as such, so we don't miss a relevant one.

For that reason putting this in "request changes" state.

Some of the issues might require Front-end Team input.

Summary of that + my own findings:

Comment thread .github/workflows/backend-ci.yaml Outdated
Comment thread .github/workflows/backend-ci.yaml Outdated
Comment thread .github/workflows/backend-ci.yaml Outdated
Comment thread .github/workflows/backend-ci.yaml Outdated
Comment thread src/lib/Translation/Extractor/typescript_translation_extractor.mjs
Comment thread src/lib/Translation/Extractor/TypeScriptExtractorClient.php Outdated
Comment thread src/lib/Translation/Extractor/TypeScriptExtractorClient.php
Comment thread src/lib/Translation/Extractor/TypeScriptFileVisitor.php
Comment thread src/lib/Translation/Extractor/TypeScriptFileVisitor.php
$this->parserScriptPath = $parserScriptPath ?? __DIR__ . '/typescript_translation_extractor.mjs';
}

public function __destruct()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP doesn't allow a return type declaration

@sonarqubecloud

Copy link
Copy Markdown

@mikadamczyk
mikadamczyk requested a review from alongosz July 27, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants