From b8c857ef6c354719f817a8db7fe941dc558c8fce Mon Sep 17 00:00:00 2001 From: Matthew Batchelder Date: Sat, 28 Sep 2024 14:02:19 -0400 Subject: [PATCH] Default the textdomain to 'default' --- README.md | 5 +++++ src/Assets/Asset.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d3d5e6a..23c8a93 100644 --- a/README.md +++ b/README.md @@ -452,6 +452,11 @@ Asset::add( 'my-thing', 'js/something.js' ) Asset::add( 'my-thing', 'js/something.js' ) ->with_translations( $textdomain, 'relative/path/to/json/lang/files' ) ->register(); + +// Using the 'default' textdomain and the default path of 'languages/'. +Asset::add( 'my-thing', 'js/something.js' ) + ->with_translations() + ->register(); ``` ### Conditional enqueuing diff --git a/src/Assets/Asset.php b/src/Assets/Asset.php index 2905338..8babbbe 100644 --- a/src/Assets/Asset.php +++ b/src/Assets/Asset.php @@ -1760,7 +1760,7 @@ public function use_asset_file( bool $use_asset_file = true ): self { * * @return self */ - public function with_translations( string $textdomain, string $path = 'languages' ): self { + public function with_translations( string $textdomain = 'default', string $path = 'languages' ): self { if ( ! $this->is_js() ) { throw new InvalidArgumentException( 'Translations may only be set for JS assets.' ); }