IBX-12091: Added TypeScript translation extraction support - #1967
IBX-12091: Added TypeScript translation extraction support#1967mikadamczyk wants to merge 7 commits into
Conversation
5198656 to
8b44786
Compare
26d6cc2 to
8b9bbb0
Compare
|
|
||
| final class TypeScriptExtractorClient | ||
| { | ||
| private const DEFAULT_RESPONSE_TIMEOUT_SECONDS = 30.0; |
There was a problem hiding this comment.
| private const DEFAULT_RESPONSE_TIMEOUT_SECONDS = 30.0; | |
| private const float DEFAULT_RESPONSE_TIMEOUT_SECONDS = 30.0; |
| * @param array<mixed> $ast | ||
| */ | ||
| public function visitPhpFile(SplFileInfo $file, MessageCatalogue $catalogue, array $ast): void | ||
| { |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.
alongosz
left a comment
There was a problem hiding this comment.
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:
| $this->parserScriptPath = $parserScriptPath ?? __DIR__ . '/typescript_translation_extractor.mjs'; | ||
| } | ||
|
|
||
| public function __destruct() |
There was a problem hiding this comment.
PHP doesn't allow a return type declaration
|



Description:
This PR adds TypeScript translation extraction support for
Translator.trans()andTranslator.transChoice()calls, including translation descriptions from@Desccomments. 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: