Detect Language / Unicode Scripts in PHP

I've created packages that depending on knowing the text script/language to decide which font to use. For that I've created php-string-script-language which will do that exactly. You include it in your project and use it as below:

use LasseRafn\StringScript;

StringScript::isThai('Hello world.'); // false
StringScript::isChinese('你好世界。'); // true

Supported scripts

It supports the following scripts.

  • Common
  • Arabic
  • Armenian
  • Bengali
  • Bopomofo
  • Braille
  • Buhid
  • Canadian Aboriginal
  • Cherokee
  • Cyrillic
  • Devanagari
  • Ethiopic
  • Georgian
  • Greek
  • Gujarati
  • Gurmukhi
  • Han
  • Hangul
  • Hanunoo
  • Hebrew
  • Hiragana
  • Inherited
  • Kannada
  • Katakana
  • Khmer
  • Lao
  • Latin
  • Limbu
  • Malayalam
  • Mongolian
  • Myanmar
  • Ogham
  • Oriya
  • Runic
  • Sinhala
  • Syriac
  • Tagalog
  • Tagbanwa
  • TaiLe
  • Tamil
  • Telugu
  • Thaana
  • Thai
  • Tibetan
  • Yi
  • Chinese (Helper for Han)
  • Japanese (Helper for Hiragana or Katakana)
Show Comments