feat: finalize i18n everywhere (monicahq/chandler#479)

This commit is contained in:
Mazarin
2023-05-05 10:07:16 +02:00
committed by GitHub
parent d6bddda44d
commit 1cbf2538e8
318 changed files with 10909 additions and 4680 deletions
+22
View File
@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -71,6 +72,7 @@ class Module extends Model
protected $fillable = [
'account_id',
'name',
'name_translation_key',
'type',
'can_be_deleted',
'reserved_to_contact_information',
@@ -111,4 +113,24 @@ class Module extends Model
return $this->belongsToMany(TemplatePage::class, 'module_template_page')
->withTimestamps();
}
/**
* Get the name attribute.
* Modules have a default name that can be translated.
* Howerer, if a name is set, it will be used instead of the default.
*
* @return Attribute<string,never>
*/
protected function name(): Attribute
{
return Attribute::make(
get: function ($value, $attributes) {
if (! $value) {
return __($attributes['name_translation_key']);
}
return $value;
}
);
}
}