Skip to content

Commit 5e27384

Browse files
committed
Fixes
1 parent cdf99d3 commit 5e27384

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/Symfony/Component/Translation/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ CHANGELOG
99
* Deprecate passing an escape character to `CsvFileLoader::setCsvControl()`
1010
* Make Xliff 2.0 attributes in segment element available as `segment-attributes`
1111
metadata returned by `XliffFileLoader` and make `XliffFileDumper` write them to the file
12+
* `XliffFileDumper` now uses the `source` metadata to create the `source` tag if available
1213

1314
7.1
1415
---
1516

16-
* `XliffFileDumper` now uses the `source` metadata to create the `source` tag if available
1717
* Mark class `DataCollectorTranslator` as `final`
1818

1919
7.0

src/Symfony/Component/Translation/Command/XliffUpdateSourcesCommand.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function configure(): void
5858
new InputOption('locales', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Specify the locale to update.', $this->enabledLocales),
5959
])
6060
->setHelp(<<<EOF
61-
The <info>%command.name%</info> command updates the source tags in XLIFF files with the default locale translation if available.
61+
The <info>%command.name%</info> command updates the source tags in XLIFF files with the default translation locale if available.
6262
6363
You can specify directories to update in the command arguments:
6464
@@ -84,7 +84,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8484
$format = $input->getOption('format');
8585

8686
if (!\array_key_exists($format, self::FORMATS)) {
87-
$io->error(sprintf('Unknown format "%s". Available formats are: %s.', $format, implode(', ', array_map(fn ($f) => '"'.$f.'"', array_keys(self::FORMATS)))));
87+
$io->error(\sprintf('Unknown format "%s". Available formats are: %s.', $format, implode(', ', array_map(fn ($f) => '"'.$f.'"', array_keys(self::FORMATS)))));
8888

8989
return self::INVALID;
9090
}
@@ -112,14 +112,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
112112
$io->title('XLIFF Source Tag Updater');
113113

114114
foreach ($transPaths as $transPath) {
115-
$io->comment(sprintf('Updating XLIFF files in <info>%s</info>...', $transPath));
115+
$io->comment(\sprintf('Updating XLIFF files in <info>%s</info>...', $transPath));
116116

117117
$translatorBag = $this->readLocalTranslations(array_unique(array_merge($locales, [$this->defaultLocale])), $domains, [$transPath]);
118118

119119
$defaultLocaleCatalogue = $translatorBag->getCatalogue($this->defaultLocale);
120120

121121
if (!$defaultLocaleCatalogue instanceof MetadataAwareInterface) {
122-
$io->error(sprintf('The default locale catalogue must implement "%s" to be used in this tool.', MetadataAwareInterface::class));
122+
$io->error(\sprintf('The default locale catalogue must implement "%s" to be used by this command.', MetadataAwareInterface::class));
123123

124124
return self::FAILURE;
125125
}
@@ -128,13 +128,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
128128
$currentCatalogue = $translatorBag->getCatalogue($locale);
129129

130130
if (!$currentCatalogue instanceof MessageCatalogue) {
131-
$io->warning(sprintf('The catalogue for locale "%s" must be an instance of "%s" to be used in this tool.', $locale, MessageCatalogue::class));
131+
$io->warning(\sprintf('The catalogue for locale "%s" must be an instance of "%s" to be used by this command.', $locale, MessageCatalogue::class));
132132

133133
continue;
134134
}
135135

136136
if (!\count($currentCatalogue->getDomains())) {
137-
$io->warning(sprintf('No messages found for locale "%s".', $locale));
137+
$io->warning(\sprintf('No messages found for locale "%s".', $locale));
138138

139139
continue;
140140
}
@@ -161,9 +161,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
161161
$this->writer->write($currentCatalogue, $format, ['path' => $transPath, 'default_locale' => $this->defaultLocale, 'xliff_version' => $xliffVersion]);
162162

163163
if (0 === $updateSourceCount) {
164-
$message = sprintf('All source tags are already up-to-date for locale "%s".', $locale);
164+
$message = \sprintf('All source tags are already up-to-date for locale "%s".', $locale);
165165
} else {
166-
$message = sprintf('Updated %d source tag%s for locale "%s".', $updateSourceCount, $updateSourceCount > 1 ? 's' : '', $locale);
166+
$message = \sprintf('Updated %d source tag%s for locale "%s".', $updateSourceCount, $updateSourceCount > 1 ? 's' : '', $locale);
167167
}
168168

169169
$io->info($message);

src/Symfony/Component/Translation/Tests/Command/XliffUpdateSourcesCommandTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Command;
12+
namespace Symfony\Component\Translation\Tests\Command;
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Console\Application;
@@ -34,8 +34,8 @@ class XliffUpdateSourcesCommandTest extends TestCase
3434
protected function setUp(): void
3535
{
3636
$this->fs = new Filesystem();
37-
$this->translationAppDir = sprintf('%s/translation-xliff-update-source-test', sys_get_temp_dir());
38-
$this->fs->mkdir(sprintf('%s/translations', $this->translationAppDir));
37+
$this->translationAppDir = \sprintf('%s/translation-xliff-update-source-test', sys_get_temp_dir());
38+
$this->fs->mkdir(\sprintf('%s/translations', $this->translationAppDir));
3939
}
4040

4141
protected function tearDown(): void
@@ -108,7 +108,7 @@ public function testFilesAreUpdatedOnlyForSpecifiedLocales()
108108

109109
public function testFilesAreUpdatedInOtherTranslationPaths()
110110
{
111-
$otherPath = sprintf('%s/other', $this->translationAppDir);
111+
$otherPath = \sprintf('%s/other', $this->translationAppDir);
112112
$this->fs->mkdir($otherPath);
113113

114114
$originalContent = $this->createXliff1('en', 'foo', 'foo', 'bar-en');
@@ -120,22 +120,22 @@ public function testFilesAreUpdatedInOtherTranslationPaths()
120120

121121
$tester->assertCommandIsSuccessful();
122122

123-
$this->assertStringContainsString(sprintf('Updating XLIFF files in %s...', $otherPath), $tester->getDisplay());
123+
$this->assertStringContainsString(\sprintf('Updating XLIFF files in %s...', $otherPath), $tester->getDisplay());
124124

125125
$expectedContent = $this->createXliff1('en', 'foo', 'bar-en', 'bar-en');
126126

127127
// other/messages.en.xlf should be updated
128128
$this->assertStringEqualsFile($enFileInOtherDir, $expectedContent);
129129

130130
// translations/messages.en.xlf should be updated
131-
$this->assertStringContainsString(sprintf('Updating XLIFF files in %s/translations...', $this->translationAppDir), $tester->getDisplay());
131+
$this->assertStringContainsString(\sprintf('Updating XLIFF files in %s/translations...', $this->translationAppDir), $tester->getDisplay());
132132
$this->assertStringEqualsFile($enFileInDefaultDir, $expectedContent);
133133
}
134134

135135
public function testFilesAreUpdatedOnlyForPathsArgument()
136136
{
137-
$fooDir = sprintf('%s/foo', $this->translationAppDir);
138-
$barDir = sprintf('%s/bar', $this->translationAppDir);
137+
$fooDir = \sprintf('%s/foo', $this->translationAppDir);
138+
$barDir = \sprintf('%s/bar', $this->translationAppDir);
139139

140140
$this->fs->mkdir([$fooDir, $barDir]);
141141

@@ -150,11 +150,11 @@ public function testFilesAreUpdatedOnlyForPathsArgument()
150150

151151
// foo/messages.en.xlf should be updated
152152
$updatedContent = $this->createXliff1('en', 'foo', 'bar-en', 'bar-en');
153-
$this->assertStringContainsString(sprintf('Updating XLIFF files in %s...', $fooDir), $tester->getDisplay());
153+
$this->assertStringContainsString(\sprintf('Updating XLIFF files in %s...', $fooDir), $tester->getDisplay());
154154
$this->assertStringEqualsFile($fileInFooDir, $updatedContent);
155155

156156
// translations/messages.en.xlf shouldn't be updated
157-
$this->assertStringNotContainsString(sprintf('Updating XLIFF files in %s/translations...', $this->translationAppDir), $tester->getDisplay());
157+
$this->assertStringNotContainsString(\sprintf('Updating XLIFF files in %s/translations...', $this->translationAppDir), $tester->getDisplay());
158158
$this->assertStringEqualsFile($fileInDefaultDir, $originalContent);
159159
}
160160

@@ -241,7 +241,7 @@ public function testComplete(array $input, array $expectedSuggestions)
241241

242242
foreach ($domainsByLocale as $locale => $domains) {
243243
foreach ($domains as $domain) {
244-
$this->createFile($this->createXliff1($locale, 'foo', 'foo', 'bar'), sprintf('%s.%s.xlf', $domain, $locale));
244+
$this->createFile($this->createXliff1($locale, 'foo', 'foo', 'bar'), \sprintf('%s.%s.xlf', $domain, $locale));
245245
}
246246
}
247247

@@ -274,7 +274,7 @@ private function createCommand(array $transPaths = [], array $enabledLocales = [
274274
$reader->addLoader('xlf', new XliffFileLoader());
275275
$writer = new TranslationWriter();
276276
$writer->addDumper('xlf', new XliffFileDumper());
277-
$transPaths[] = sprintf('%s/translations', $this->translationAppDir);
277+
$transPaths[] = \sprintf('%s/translations', $this->translationAppDir);
278278

279279
$command = new XliffUpdateSourcesCommand($writer, $reader, 'en', $transPaths, $enabledLocales);
280280
$application->add($command);
@@ -323,7 +323,7 @@ private function createXliff2(string $locale, string $name, string $source, stri
323323

324324
private function createFile(string $content, string $filename, string $directory = 'translations'): string
325325
{
326-
$filename = sprintf('%s/%s/%s', $this->translationAppDir, $directory, $filename);
326+
$filename = \sprintf('%s/%s/%s', $this->translationAppDir, $directory, $filename);
327327
file_put_contents($filename, $content);
328328

329329
return $filename;

0 commit comments

Comments
 (0)