<?
if ($POST['action'] == "") { ?>
<form method="post" action="etranslate.php">
<input type='hidden' name='action' value='1'>
<textarea id="elm1" name="elm1" rows="10" cols="90"></textarea>
<input type="submit" name="save" value="Submit" />
<input type="reset" name="reset" value="Reset" />
</form>
<?
} else {
echo "".AutoDetectLang($POST['elm1']);
}
function AutoDetectLang($str) {
if (preg_match('/[\ก|\ข|\ฃ|\ค|\ฅ|\ฆ|\ง|\จ|\ฉ|\ช|\ซ|\ฌ|\ญ||@|&]/', $str)) {
echo "THAI was found.";
} else {
echo "THAI was not found.";
}
if (preg_match('/[\诶|\比|\西|\迪|\伊|\艾弗|\吉|\艾尺|\艾|\杰|\开|\艾勒|\艾马||@|&]/', $str)) {
echo "CHINESE was found.";
} else {
echo "CHINESE was not found.";
}
}
?>
and I changed php.ini to:
[mbstring]
; language for internal character representation.
mbstring.language = Neutral
; internal/script encoding.
; Some encoding cannot work as internal encoding.
; (e.g. SJIS, BIG5, ISO-2022-*)
mbstring.internal_encoding = UTF-8
; http input encoding.
mbstring.http_input = auto
; http output encoding. mb_output_handler must be
; registered as output buffer to function
mbstring.http_output = UTF-8
; enable automatic encoding translation according to
; mbstring.internal_encoding setting. Input chars are
; converted to internal encoding by setting this to On.
; Note: Do not use automatic encoding translation for
; portable libs/applications.
mbstring.encoding_translation = On
; automatic encoding detection order.
; auto means
mbstring.detect_order = auto
; substitute_character used when character cannot be converted
; one from another
;mbstring.substitute_character = none;
; overload(replace) single byte functions by mbstring functions.
; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(),
; etc. Possible values are 0,1,2,4 or combination of them.
; For example, 7 for overload everything.
; 0: No overload
; 1: Overload mail() function
; 2: Overload str() functions
; 4: Overload ereg() functions
mbstring.func_overload = 2
; enable strict encoding detection.
;mbstring.strict_encoding = Off
Because I was thinking, doing a check on foeign characters first and after that within the latin characters do a check on words (like yours and, a, an)