Hi Roots,
I noticed any string translations used for i18n localization are not working in the ./app directory. All other --include="app,config,resources,public/dist/js" inside the ./package.json are working and are written inside the ./resources/lang/radicle.pot.
Directory app
It seems the wp i18n make-pot can’t scan the ./app directory since none of the string translations like __(‘My example string‘, 'radicle'); are saved in the radicle.pot.
Usages in x-components
I also found the string translations won’t be saved to the radicle.pot when you pass a string translation as prop attribute to the Component.
// .resources/views/partials/content-none.blade.php
<x-no-results
:title="__('My title is not written inside the radicle.pot file.', 'radicle')"
:text="__('The content-none.blade.php gets scanned but these component constructor prop attributes are not inside the radicle.pot file.', 'radicle')"
/>
<p>{{ __('This a string translation I can translate.', 'radicle') }}</p>
I assume it’s because the Component runs inside the ./app directory at ./app/View/Components/NoResult.php.
<?php
namespace App\View\Components;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class NoResults extends Component
{
/**
* Create a new component instance.
*/
public function __construct(
public ?string $title = null,
public ?string $subtitle = null,
) {
//
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.no-results');
}
}
Even though the x-no-results is inside .resources/ the string translations won’t get recognized once they are inside the x-component prop. So the localization is not working in ./app & x-component props. Do you have any suggestions on how to resolve these issues?
Looking forward to your insights.
Best regards,
Lex