Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 54 additions & 38 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function createNotification($recipient, $entity, $spam_detections, $ip)
$detected_details = [];
foreach ($spam_detections as $detection) {
$translated_field = isset($field_translations[$detection['field']]) ? $field_translations[$detection['field']] : $detection['field'];
$detected_details[] = "Campo: $translated_field, Termos: " . implode(', ', $detection['terms']) . '<br>';
$detected_details[] = i::__("Campo") . ": " . $translated_field . ", " . i::__("Termos") . ": " . implode(', ', $detection['terms']) . "<br>";
}

$dict_entity = $this->dictEntity($entity, 'artigo');
Expand All @@ -254,14 +254,19 @@ public function createNotification($recipient, $entity, $spam_detections, $ip)
$content = $mustache->render($template, $params);

if ($email = $this->getAdminEmail($recipient)) {
$app->createAndSendMailMessage([
'from' => $app->config['mailer.from'],
'to' => $email,
'subject' => $is_save ? i::__("Spam - Conteúdo suspeito") : i::__("Spam - {$dict_entity} foi bloqueado(a)"),
'body' => $content,
]);
}
// TRANSLATORS: Subject of email reporting content flagged as suspicious or blocked
$subject = $is_save
? i::__("Spam - Conteúdo suspeito") : sprintf(i::__("Spam - %s foi bloqueado(a)"), $dict_entity);

$app->createAndSendMailMessage([
'from' => $app->config['mailer.from'],
'to' => $email,
'subject' => $subject,
'body' => $content,
]);
}


// Salvar metadado
$date_time = new DateTime();
$date_time->add(new \DateInterval('PT10S'));
Expand All @@ -286,37 +291,49 @@ public function createNotification($recipient, $entity, $spam_detections, $ip)
* @return string
*/
public function dictEntity(Entity $entity, $type = "preposição"): string
{
$class = $entity->getClassName();
{
$class = $entity->getClassName();

switch ($type) {
case 'preposição':
// TRANSLATORS: 'na' and 'no' are prepositions meaning 'in the (f)' and 'in the (m)'
$prefixes = (object) [
'f' => i::__('na'), // feminino
'm' => i::__('no'), // masculino
];
break;
case 'pronome':
// TRANSLATORS: 'esta' and 'este' are demonstrative pronouns (this-f, this-m)
$prefixes = (object) [
'f' => i::__('esta'),
'm' => i::__('este'),
];
break;
case 'artigo':
// TRANSLATORS: 'a' and 'o' are definite articles (the-f, the-m)
$prefixes = (object) [
'f' => i::__('a'),
'm' => i::__('o'),
];
break;
case 'none':
default:
$prefixes = (object) ['f' => '', 'm' => ''];
break;
}

switch ($type) {
case 'preposição':
$prefixes = (object) ["f" => "na", "m" => "no"];
break;
case 'pronome':
$prefixes = (object) ["f" => "esta", "m" => "este"];
break;
case 'artigo':
$prefixes = (object) ["f" => "a", "m" => "o"];
break;
case 'none':
$prefixes = (object) ["f" => "", "m" => ""];
break;
default:
$prefixes = (object) ["f" => "", "m" => ""];
break;
}
$entities = [
// TRANSLATORS: %s is a prefix like 'na', 'esta', 'a'
Agent::class => sprintf(i::__('%s Agente'), $prefixes->m),
Opportunity::class => sprintf(i::__('%s Oportunidade'), $prefixes->f),
Project::class => sprintf(i::__('%s Projeto'), $prefixes->m),
Space::class => sprintf(i::__('%s Espaço'), $prefixes->m),
Event::class => sprintf(i::__('%s Evento'), $prefixes->m),
];

$entities = [
Agent::class => "{$prefixes->m} Agente",
Opportunity::class => "{$prefixes->f} Oportunidade",
Project::class => "{$prefixes->m} Projeto",
Space::class => "{$prefixes->m} Espaço",
Event::class => "{$prefixes->m} Evento",
];
return $entities[$class];
}

return $entities[$class];
}

/**
* Retorna o texto com o nome da tabela
Expand Down Expand Up @@ -396,8 +413,7 @@ public function getSpamTerms($entity, $terms): array {
$lowercase_term = $this->formatText($term);
$_term = implode("{$special_chars}", mb_str_split($lowercase_term));

$pattern = '/([^\w]|[_0-9]|^)' . $_term . '([^\w]|[_0-9]|$)/';

$pattern = '/([^\w]|[_0-9]|^)' . preg_quote($_term, '/') . '([^\w]|[_0-9]|$)/';
if (preg_match($pattern, $lowercase_value) && !in_array($term, $found_terms)) {
$found_terms[$field][] = $term;
}
Expand Down
6 changes: 5 additions & 1 deletion components/spam-add-config/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
<span class="spam-add-config__title semibold"> <?= i::__('Notificações')?></span>
<div class="field">
<input type="text" placeholder="Digite uma nova palavra chave de notificação" @keydown="change($event, 'notificationTags')" @blur="clear($event)">
<input type="text" placeholder="<?= i::esc_attr__('Digite uma nova palavra chave de notificação') ?>" @keydown="change($event, 'notificationTags')" @blur="clear($event)">

</div>
</div>
<mc-tag-list class="spam-add-config__tags scrollbar" classes="spam-add-config__tag spam-add-config__tag--notification" :tags="notificationTags" @remove="saveTags()" editable></mc-tag-list>
Expand All @@ -41,6 +43,8 @@
<span class="spam-add-config__title semibold"> <?= i::__('Bloqueio')?></span>
<div class="field">
<input type="text" placeholder="Digite uma nova palavra chave de bloqueio" @keydown="change($event, 'blockedTags')" @blur="clear($event)">
<input type="text" placeholder="<?= i::esc_attr__('Digite uma nova palavra chave de bloqueio') ?>" @keydown="change($event, 'blockedTags')" @blur="clear($event)">

</div>
</div>
<mc-tag-list class="spam-add-config__tags scrollbar" classes="spam-add-config__tag spam-add-config__tag--block" :tags="blockedTags" @remove="saveTags()" editable></mc-tag-list>
Expand All @@ -49,4 +53,4 @@
</template>
</mc-modal>

</div>
</div>
Binary file modified translations/es_ES.mo
Binary file not shown.
110 changes: 70 additions & 40 deletions translations/es_ES.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: mapas\n"
"POT-Creation-Date: 2025-05-08 14:53-0300\n"
"POT-Creation-Date: 2025-06-16 14:48-0300\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: librecoop\n"
Expand All @@ -24,38 +24,101 @@ msgstr "Fecha de envío del correo electrónico"
msgid "Classificar como Spam"
msgstr "Clasificar como spam"

#: plugin-SpamDetector/Plugin.php:220
#: plugin-SpamDetector/Plugin.php:223
msgid "Nome"
msgstr "Nombre"

#: plugin-SpamDetector/Plugin.php:221
#: plugin-SpamDetector/Plugin.php:224
msgid "Descrição Curta"
msgstr "Descripción breve"

#: plugin-SpamDetector/Plugin.php:222
#: plugin-SpamDetector/Plugin.php:225
msgid "Descrição Longa"
msgstr "Descripción Larga"

#: plugin-SpamDetector/Plugin.php:233
#: plugin-SpamDetector/Plugin.php:231
msgid "Campo"
msgstr "Campo"

#: plugin-SpamDetector/Plugin.php:231
msgid "Termos"
msgstr "Términos"

#: plugin-SpamDetector/Plugin.php:236
msgid ""
"O sistema detectou possível spam em um conteúdo recente. Por favor, revise "
"as informações abaixo e tome as medidas necessárias:"
msgstr ""
"El sistema ha detectado posible spam en contenido reciente. Revise la "
"siguiente información y tome las medidas adecuadas:"

#: plugin-SpamDetector/Plugin.php:234
#: plugin-SpamDetector/Plugin.php:237
msgid ""
"O sistema detectou um conteúdo inadequado neste cadastro e moveu-o para a "
"lixeira. Seguem abaixo os dados para análise do conteúdo:"
msgstr ""
"El sistema detectó contenido inapropiado en este registro y lo movió a la "
"papelera. A continuación se muestran los datos para el análisis de contenido:"

#: plugin-SpamDetector/Plugin.php:257
#: plugin-SpamDetector/Plugin.php:259
msgid "Spam - Conteúdo suspeito"
msgstr "Spam - Contenido sospechoso"

#: plugin-SpamDetector/Plugin.php:259
#, php-format
msgid "Spam - %s foi bloqueado(a)"
msgstr "Spam - %s fue bloqueado(a)"

#: plugin-SpamDetector/Plugin.php:301
msgid "na"
msgstr "en la"

#: plugin-SpamDetector/Plugin.php:302
msgid "no"
msgstr "en el"

#: plugin-SpamDetector/Plugin.php:308
msgid "esta"
msgstr "esta"

#: plugin-SpamDetector/Plugin.php:309
msgid "este"
msgstr "este"

#: plugin-SpamDetector/Plugin.php:315
msgid "a"
msgstr "hasta"

#: plugin-SpamDetector/Plugin.php:316
msgid "o"
msgstr "el"

#. TRANSLATORS: %s is a prefix like 'na', 'esta', 'a'
#: plugin-SpamDetector/Plugin.php:327
#, php-format
msgid "%s Agente"
msgstr "%s Agente"

#: plugin-SpamDetector/Plugin.php:328
#, php-format
msgid "%s Oportunidade"
msgstr "%s Oportunidad"

#: plugin-SpamDetector/Plugin.php:329
#, php-format
msgid "%s Projeto"
msgstr "%s Proyecto"

#: plugin-SpamDetector/Plugin.php:330
#, php-format
msgid "%s Espaço"
msgstr "%s Espacio"

#: plugin-SpamDetector/Plugin.php:331
#, php-format
msgid "%s Evento"
msgstr "%s Evento"

#: plugin-SpamDetector/components/spam-add-config/template.php:17
msgid "Controle de Spam"
msgstr "Control de spam"
Expand Down Expand Up @@ -338,9 +401,6 @@ msgstr "Acceda a la gestión de usuarios haciendo clic aquí"
#~ "Agente colectivo sin RUT , con los campos Fecha de Nacimiento / Fundación "
#~ "e Email privado completos"

#~ msgid "Espaço"
#~ msgstr "Espacio"

#~ msgid "Vincule um espaço a sua inscrição"
#~ msgstr "Es obligatorio vincular un espacio a la inscripción"

Expand All @@ -353,30 +413,18 @@ msgstr "Acceda a la gestión de usuarios haciendo clic aquí"
#~ msgid "Site"
#~ msgstr "Página web"

#~ msgid "Evento"
#~ msgstr "Evento"

#~ msgid "Eventos"
#~ msgstr "Eventos"

#~ msgid "Agente"
#~ msgstr "Agente"

#~ msgid "Agentes"
#~ msgstr "Agentes"

#~ msgid "Espaços"
#~ msgstr "Espacios"

#~ msgid "Projeto"
#~ msgstr "Proyecto"

#~ msgid "Projetos"
#~ msgstr "Proyectos"

#~ msgid "Oportunidade"
#~ msgstr "Oportunidad"

#~ msgid "Oportunidades"
#~ msgstr "Oportunidades"

Expand Down Expand Up @@ -8715,9 +8763,6 @@ msgstr "Acceda a la gestión de usuarios haciendo clic aquí"
#~ msgid "(0 = Sem limitações)"
#~ msgstr "(0 = Sin limitaciones)"

#~ msgid "Campo"
#~ msgstr "Campo"

#~ msgid "Valor"
#~ msgstr "Valor"

Expand Down Expand Up @@ -9721,9 +9766,6 @@ msgstr "Acceda a la gestión de usuarios haciendo clic aquí"
#~ msgid "Política de privacidade"
#~ msgstr "Política de privacidad"

#~ msgid "Termos de uso"
#~ msgstr "Términos de uso"

#~ msgid "Autorização de uso de imagem"
#~ msgstr "Autorización de uso de imagen"

Expand Down Expand Up @@ -10469,9 +10511,6 @@ msgstr "Acceda a la gestión de usuarios haciendo clic aquí"
#~ msgid "resultado final"
#~ msgstr "resultado final"

#~ msgid "estado"
#~ msgstr "departamento"

#~ msgid "coletivo"
#~ msgstr "colectivo"

Expand Down Expand Up @@ -10881,9 +10920,6 @@ msgstr "Acceda a la gestión de usuarios haciendo clic aquí"
#~ msgid "de"
#~ msgstr "de"

#~ msgid "a"
#~ msgstr "hasta"

#~ msgid "Preencher formulário"
#~ msgstr "Rellenar formulario"

Expand Down Expand Up @@ -14151,9 +14187,6 @@ msgstr "Acceda a la gestión de usuarios haciendo clic aquí"
#~ msgid "Bloqueio de campos"
#~ msgstr "Bloqueo de campos"

#~ msgid "ano"
#~ msgstr "año"

#~ msgid "anos"
#~ msgstr "años"

Expand Down Expand Up @@ -19827,6 +19860,3 @@ msgstr "Acceda a la gestión de usuarios haciendo clic aquí"

#~ msgid "Clique para marcar/desmarcar este"
#~ msgstr "Haga clic para marcar/desmarcar este"

#~ msgid "teste pt"
#~ msgstr "teste es"