first commit

This commit is contained in:
root
2025-06-18 10:31:43 +08:00
commit d9f820b55d
981 changed files with 449311 additions and 0 deletions

355
app/Helpers/TitleHelper.php Executable file
View File

@ -0,0 +1,355 @@
<?php
namespace App\Helpers;
use App\Enums\ArticleStyleEnum;
use App\Enums\LocationEnum;
class TitleHelper
{
public static function translate(string $englishTitle)
{
$map = [
'Madrid' => [
[
'preg' => '/Madrid Spring ([0-9]*?)/',
'trans' => '春季',
'style' => ArticleStyleEnum::NULL->value,
'location' => LocationEnum::MADRID->value,
],[
'preg' => '/Madrid Fall ([0-9]*?)/',
'trans' => '秋季',
'style' => ArticleStyleEnum::NULL->value,
'location' => LocationEnum::MADRID->value,
],
],
'Spain' => [
[
'preg' => '/Spain Spring ([0-9]*?)/',
'trans' => '春季',
'style' => ArticleStyleEnum::NULL->value,
'location' => LocationEnum::SPAIN->value,
],[
'preg' => '/Spain Fall ([0-9]*?)/',
'trans' => '秋季',
'style' => ArticleStyleEnum::NULL->value,
'location' => LocationEnum::SPAIN->value,
],
],
'Istanbul' => [
[
'preg' => '/Istanbul Spring ([0-9]*?)/',
'trans' => '春季',
'style' => ArticleStyleEnum::NULL->value,
'location' => LocationEnum::ISTANBUL->value,
],[
'preg' => '/Istanbul Fall ([0-9]*?)/',
'trans' => '秋季',
'style' => ArticleStyleEnum::NULL->value,
'location' => LocationEnum::ISTANBUL->value,
],
],
'Lagos' => [
[
'preg' => '/Lagos Spring ([0-9]*?)/',
'trans' => '春季',
'style' => ArticleStyleEnum::NULL->value,
'location' => LocationEnum::LAGOS->value,
],[
'preg' => '/Lagos Fall ([0-9]*?)/',
'trans' => '秋季',
'style' => ArticleStyleEnum::NULL->value,
'location' => LocationEnum::LAGOS->value,
],
],
'Russia' => [
[
'preg' => '/Russia Spring ([0-9]*?)/',
'trans' => '春季',
'style' => ArticleStyleEnum::NULL->value,
'location' => LocationEnum::RUSSIA->value,
],[
'preg' => '/Russia Fall ([0-9]*?)/',
'trans' => '秋季',
'style' => ArticleStyleEnum::NULL->value,
'location' => LocationEnum::RUSSIA->value,
],
],
'Shanghai' => [
[
'preg' => '/Shanghai Spring ([0-9]*?)/',
'trans' => '春季',
'style' => ArticleStyleEnum::NULL->value,
'location' => LocationEnum::SHANGHAI->value,
],[
'preg' => '/Shanghai Fall ([0-9]*?)/',
'trans' => '秋季',
'style' => ArticleStyleEnum::NULL->value,
'location' => LocationEnum::SHANGHAI->value,
],
],
'Bridal' => [
[
'preg' => '/Bridal Spring ([0-9]*?)/',
'trans' => '春季婚纱礼服',
'style' => ArticleStyleEnum::BRIDAL->value,
'location' => LocationEnum::NULL->value,
],[
'preg' => '/Bridal Fall ([0-9]*?)/',
'trans' => '秋季婚纱礼服',
'style' => ArticleStyleEnum::BRIDAL->value,
'location' => LocationEnum::NULL->value,
],
],
'Australia' => [
[
'preg' => '/Australia Resort ([0-9]*)/',
'trans' => '度假系列',
'style' => 1,
'location' => LocationEnum::AUSTRALIA->value,
],[
'preg' => '/Australia Spring ([0-9]*)/',
'trans' => '春季',
'style' => 0,
'location' => LocationEnum::AUSTRALIA->value,
],
],
'Menswear' => [
[
'preg' => '/Spring ([0-9]*?) Menswear/',
'trans' => '春季男装',
'style' => 0,
'location' => 0,
],[
'preg' => '/Fall ([0-9]*?) Menswear/',
'trans' => '秋季男装',
'style' => 0,
'location' => 0,
]
],
'Ukraine' => [
[
'preg' => '/Ukraine Fall ([0-9]*)/',
'trans' => '秋季',
'style' => 0,
'location' => LocationEnum::UKRAINE->value, // 乌克兰
],
[
'preg' => '/Ukraine Spring ([0-9]*)/',
'trans' => '春季',
'style' => 0,
'location' => LocationEnum::UKRAINE->value, // 乌克兰
],
],
'Kiev' => [
[
'preg' => '/Kiev Fall ([0-9]*)/',
'trans' => '秋季',
'style' => 0,
'location' => LocationEnum::KIEV->value, // 基辅
],[
'preg' => '/Kiev Spring ([0-9]*)/',
'trans' => '春季',
'style' => 0,
'location' => LocationEnum::KIEV->value, // 基辅
]
],
'Stockholm' => [
[
'preg' => '/Stockholm Fall ([0-9]*)/',
'trans' => '秋季',
'style' => 0,
'location' => LocationEnum::STOCKHOLM->value, // 斯德哥尔摩
],
[
'preg' => '/Stockholm Spring ([0-9]*)/',
'trans' => '春季',
'style' => 0,
'location' => LocationEnum::STOCKHOLM->value, // 斯德哥尔摩
],
],
'Tbilisi' => [
[
'preg' => '/Tbilisi Fall ([0-9]*)/',
'trans' => '秋季',
'style' => 0,
'location' => LocationEnum::TBILISI->value, // 斯德哥尔摩
],
[
'preg' => '/Tbilisi Spring ([0-9]*)/',
'trans' => '春季',
'style' => 0,
'location' => LocationEnum::TBILISI->value, // 斯德哥尔摩
],
],
'Mexico' => [
[
'preg' => '/Mexico Fall ([0-9]*)/',
'trans' => '秋季',
'style' => 0,
'location' => LocationEnum::MEXICO->value, // 斯德哥尔摩
],[
'preg' => '/Mexico Spring ([0-9]*)/',
'trans' => '秋季',
'style' => 0,
'location' => LocationEnum::MEXICO->value, // 斯德哥尔摩
],[
'preg' => '/Mexico City Fall ([0-9]*)/',
'trans' => '城市秋季',
'style' => 0,
'location' => LocationEnum::MEXICO->value, // 斯德哥尔摩
],[
'preg' => '/Mexico City Spring ([0-9]*)/',
'trans' => '城市春季',
'style' => 0,
'location' => LocationEnum::MEXICO->value, // 斯德哥尔摩
],
],
'Tokyo' => [
[
'preg' => '/Tokyo Spring ([0-9]*)/',
'trans' => '春季',
'style' => 0,
'location' => LocationEnum::TOKYO->value, // 东京
],[
'preg' => '/Tokyo Fall ([0-9]*)/',
'trans' => '秋季',
'style' => 0,
'location' => LocationEnum::TOKYO->value, // 东京
],
],
'Berlin' => [
[
'preg' => '/Berlin Fall ([0-9]*)/',
'trans' => '秋季',
'style' => 0,
'location' => LocationEnum::BERLIN->value, // 柏林
],
[
'preg' => '/Berlin Spring ([0-9]*)/',
'trans' => '春季',
'style' => 0,
'location' => LocationEnum::BERLIN->value, // 柏林
],
],
'Copenhagen' => [
[
'preg' => '/Copenhagen Fall ([0-9]*)/',
'trans' => '秋季',
'style' => 0,
'location' => LocationEnum::COPENHAGEN->value, // 哥本哈根
],[
'preg' => '/Copenhagen Spring ([0-9]*)/',
'trans' => '春季',
'style' => 0,
'location' => LocationEnum::COPENHAGEN->value, // 哥本哈根
],
],
'São Paulo' => [
[
'preg' => '/São Paulo Fall ([0-9]*)/',
'trans' => '秋季',
'style' => 0,
'location' => LocationEnum::SAO_PAULO->value, // 哥本哈根
],[
'preg' => '/São Paulo Spring ([0-9]*)/',
'trans' => '春季',
'style' => 0,
'location' => LocationEnum::SAO_PAULO->value, // 哥本哈根
],
],
'SEOUL' => [
[
'preg' => '/Seoul Spring ([0-9]*)/',
'trans' => '春季',
'style' => 0,
'location' => LocationEnum::SEOUL->value,
],[
'preg' => '/Seoul Fall ([0-9]*)/',
'trans' => '秋季',
'style' => 0,
'location' => LocationEnum::SEOUL->value,
],
],
'Spring' => [
[
'preg' => '/([0-9]*?) Spring Summer/',
'trans' => '春夏',
'style' => 0,
'location' => 0,
],
],
'Autumn Winter' => [
[
'preg' => '/([0-9]*?) Autumn Winter/',
'trans' => '秋冬',
'style' => 0,
'location' => 0,
],
],
'Ready-to-Wear' => [
[
'preg' => '/Fall ([0-9]*?) Ready-to-Wear/',
'trans' => '秋季成衣',
'style' => 0,
'location' => 0,
],[
'preg' => '/Spring ([0-9]*?) Ready-to-Wear/',
'trans' => '春季成衣',
'style' => 0,
'location' => 0,
],
],
'Resort' => [
[
'preg' => '/Resort ([0-9]*?)/',
'trans' => '度假系列',
'style' => ArticleStyleEnum::RESORT->value,
'location' => LocationEnum::NULL->value,
],
],
'Couture' => [
[
'preg' => '/Spring ([0-9]*?) Couture/',
'trans' => '春季高订系列',
'style' => ArticleStyleEnum::RESORT->value,
'location' => LocationEnum::NULL->value,
],
[
'preg' => '/Fall ([0-9]*?) Couture/',
'trans' => '秋季高订系列',
'style' => ArticleStyleEnum::RESORT->value,
'location' => LocationEnum::NULL->value,
],
],
'Pre-Fall' => [
[
'preg' => '/Pre-Fall ([0-9]*)/',
'trans' => '早秋',
'style' => 0,
'location' => 0,
],
],
];
$res = $englishTitle;
foreach ($map as $keyword => $pregMap) {
if (stripos($englishTitle, $keyword) !== false) {
foreach ($pregMap as $pregItem) {
preg_match_all($pregItem['preg'], $englishTitle, $matches);
if (count($matches) > 1 && $matches[1]) {
$res = trim(current($matches[1]) . " {$pregItem['trans']}");
break;
}
}
if ($res) {
break;
}
}
}
return $res;
}
}