Skip to content

Commit 8124926

Browse files
committed
fix(i18n): small finishing fixes
- use sharable instead of shareable by default - run phpcbf on the translation file resulted from extraction - add help message on extraction success - add spacing rule for array declaration to fix style of translations
1 parent b9dab37 commit 8124926

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

parameters.yaml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ parameters:
55
app.siteName: 'Antilope'
66
app.sharableNames:
77
en:
8-
name: shareable
8+
name: sharable
99
gender: neuter
1010
app.emailAddress: '[email protected]'
1111
app.siteDescription: 'A sharable Network'

phpcs.xml.dist

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<!-- Add some rules -->
3535
<rule ref="Generic.Metrics.NestingLevel"></rule>
3636
<rule ref="Generic.Arrays.ArrayIndent"></rule>
37+
<rule ref="Squiz.Arrays.ArrayDeclaration.SpaceAfterKeyword"></rule>
3738
<rule ref="Generic.Files.LineLength">
3839
<exclude-pattern>*/translations/*</exclude-pattern>
3940
</rule>

src/Command/TranslationExtractCommand.php

+15-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use Symfony\Component\Console\Output\NullOutput;
3434
use Symfony\Component\Console\Output\OutputInterface;
3535
use Symfony\Component\Console\Style\SymfonyStyle;
36+
use Symfony\Component\Translation\MessageCatalogueInterface;
3637

3738
class TranslationExtractCommand extends Command
3839
{
@@ -65,14 +66,25 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6566
];
6667
$end = $input->getOption('all') ? sizeof(self::LOCALES) : 1;
6768
for ($i = 0; $i < $end; $i++) {
68-
$args['locale'] = self::LOCALES[$i];
69+
$locale = self::LOCALES[$i];
70+
$args['locale'] = $locale;
6971
$code = $updateCmd->run(new ArrayInput($args), new NullOutput());
7072
if ($code == Command::FAILURE) {
71-
array_push($failures, self::LOCALES[$i]);
73+
array_push($failures, $locale);
74+
} else {
75+
$file = sprintf(
76+
'translations/%s%s.%s.%s',
77+
self::DOMAIN,
78+
MessageCatalogueInterface::INTL_DOMAIN_SUFFIX,
79+
$locale,
80+
self::FORMAT
81+
);
82+
exec("vendor/bin/phpcbf $file");
7283
}
7384
}
7485
if (sizeof($failures) === 0) {
75-
$io->success('The translations have been correcty extracted');
86+
// phpcs:ignore Generic.Files.LineLength
87+
$io->success('The translations have been correcty extracted. Edit the new values and remove the untranslated ones.');
7688
return Command::SUCCESS;
7789
} else {
7890
$vars = implode(', ', $failures);

src/Service/AntilopeFormatter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class AntilopeFormatter extends MessageFormatter
3434
protected const NAME = 'name';
3535
protected const GENDER = 'gender';
3636
protected const DEFAULT = [
37-
self::NAME => 'shareable',
37+
self::NAME => 'sharable',
3838
self::GENDER => 'neuter',
3939
];
4040
protected $params;

0 commit comments

Comments
 (0)