feat: implement real-time SEO character counters and improve default avatar handling and translation logic.

This commit is contained in:
Ümit Tunç
2026-08-07 23:25:40 +03:00
parent 32b3f5187d
commit a51af8208d
7 changed files with 91 additions and 5 deletions
+19 -2
View File
@@ -45,14 +45,14 @@ trait HasTranslations
// 1. Try translations table
$translation = $this->getTranslation($fieldName, $languageCode);
if ($translation && !empty($translation->field_value)) {
if ($translation && $this->hasValidTranslationContent($translation->field_value)) {
return $translation->field_value;
}
// 2. Fallback to default language from translations table
if ($fallback && $languageCode !== $this->getDefaultLanguageCode()) {
$defaultTranslation = $this->getTranslation($fieldName, $this->getDefaultLanguageCode());
if ($defaultTranslation && !empty($defaultTranslation->field_value)) {
if ($defaultTranslation && $this->hasValidTranslationContent($defaultTranslation->field_value)) {
return $defaultTranslation->field_value;
}
}
@@ -267,6 +267,23 @@ trait HasTranslations
}
}
/**
* Check if translation content has meaningful text or media
*/
protected function hasValidTranslationContent(mixed $value): bool
{
if (empty($value)) {
return false;
}
if (is_string($value)) {
$stripped = trim(strip_tags($value, '<img><iframe><video><audio>'));
return $stripped !== '';
}
return true;
}
/**
* Get translatable fields for this model
*/