locale.php 620 B

12345678910111213141516171819202122232425
  1. <?php
  2. require_once(DIR.'/lib/gettext.inc');
  3. @$locales = explode(',',$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
  4. $langs = scandir(DIR.'/lang');
  5. $found = false;
  6. foreach($locales as $k => $l){
  7. $locale = str_replace('-','_',$l);
  8. foreach($langs as $lang){
  9. if($lang != '.' && $lang != '..' && strtolower($lang) == strtolower($locale)){
  10. $locale = $lang;
  11. $found = true;
  12. break;
  13. }
  14. }
  15. if($found){
  16. break;
  17. }
  18. $locale = 'en';
  19. }
  20. define('LOCALE',$locale);
  21. T_setlocale(LC_MESSAGES,LOCALE);
  22. T_bindtextdomain('omninet',DIR.'/lang');
  23. T_bind_textdomain_codeset('omninet','UTF-8');
  24. T_textdomain('omninet');
  25. ?>