<?php

namespace App\Support\Services\Localization;

class LanguageDetector
{
    public function detect(string $text): string
    {
        // Arabic
        if (preg_match('/\p{Arabic}/u', $text)) {
            return 'ar';
        }

        // English
        if (preg_match('/[a-zA-Z]/', $text)) {
            return 'en';
        }

        // Chinese
        if (preg_match('/\p{Han}/u', $text)) {
            return 'zh';
        }

        return 'ar';
    }
}