Skip to content

Commit

Permalink
fix translations filename
Browse files Browse the repository at this point in the history
  • Loading branch information
yceruto committed Dec 18, 2023
1 parent 20a7da0 commit 1d683d9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Maker/BundleFileMaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public function make(BundleOptions $options): void
if ($options->hasWebAssets) {
$this->fileCreator->create('assets/acme-bundle.js', [
'bundle-name' => Inflector::className($options->name),
], 'assets/'.Inflector::fileName($options->name, 'js'));
], sprintf('assets/%s.js', Inflector::fileName($options->name)));

$this->fileCreator->create('public/acme-bundle.min.js', [
'bundle-name' => Inflector::className($options->name),
], 'public/'.Inflector::fileName($options->name, 'min.js'));
], sprintf('public/%s.min.js', Inflector::fileName($options->name)));
}

if ($options->hasConfig) {
Expand Down Expand Up @@ -62,7 +62,7 @@ public function make(BundleOptions $options): void
if ($options->hasTranslations) {
$this->fileCreator->create('translations/AcmeBundle.fr.xlf', [
'vendor-prefix' => Inflector::vendory($options->name),
]);
], sprintf('translations/%s.fr.xlf', Inflector::className($options->name)));
}
}
}
4 changes: 2 additions & 2 deletions src/Utils/Inflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public static function vendory(string $name): string
return strtolower(substr($name, 0, strpos($name, '-')));
}

public static function fileName(string $name, string $ext): string
public static function fileName(string $name): string
{
return sprintf('%s.%s', strtolower(substr($name, strrpos($name, '/') + 1)), $ext);
return strtolower(substr($name, strrpos($name, '/') + 1));
}
}
2 changes: 1 addition & 1 deletion tests/Utils/InflectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public function testVendoryPackageName(): void

public function testFileName(): void
{
self::assertSame('acme-bundle.js', Inflector::fileName('acme/acme-bundle', 'js'));
self::assertSame('acme-bundle', Inflector::fileName('acme/acme-bundle'));
}
}

0 comments on commit 1d683d9

Please sign in to comment.