Many parameters provide a translatable alternative: when populated with an identifier for the native Laravel's localization functions, those assign a translated string to the reference attribute.
@php
App::setLocale('it');
@endphp
<x-larastrap::button tlabel="example.label" />
<button id="button-e6410fbd" class="btn btn-primary">Questa è una etichetta</button>
Those attributes are inherited by all Inputs and other components usually used in Forms.
@php
App::setLocale('it');
@endphp
<x-larastrap::text tlabel="example.name" />
<x-larastrap::email tlabel="example.email" />
<div class="row mb-3">
<label for="input-df649f8f" class="col-4 col-form-label">Nome</label>
<div class="col-8">
<input id="input-df649f8f" type="text" class="form-control" name="uyWMFDWw9R" value="">
</div>
</div>
<div class="row mb-3">
<label for="input-604cd35c" class="col-4 col-form-label">Indirizzo E-Mail</label>
<div class="col-8">
<input id="input-604cd35c" type="email" class="form-control" name="f5rH46Hojn" value="">
</div>
</div>
Within the "options" parameter of Select, Checks and other similar widgets, it is possible to use dedicated attributes for strings to be translated.
Optionally you can define your own function to resolve translations starting from the identifier passed as parameter to each component, instead of native __()
Laravel function.
Add a translate
key to the global configuration array in config/larastrap.php
.
[
'translate' => function($identifier) {
return myOwnFunction($identifier);
}
]