locale.php 548 B

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