i18n.js.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. session_start();
  3. if (empty($_SESSION['language'])) {
  4. $_SESSION['language'] = 'en';
  5. }
  6. require_once($_SERVER['DOCUMENT_ROOT'].'/inc/i18n/'.$_SESSION['language'].'.php');
  7. if (!function_exists('_translate')) {
  8. function _translate() {
  9. global $LANG;
  10. $args = func_get_args();
  11. $l = $args[0];
  12. if (!$l) return 'NO LANGUAGE DEFINED';
  13. $key = $args[1];
  14. if (!isset($LANG[$l])) {
  15. require_once($_SERVER['DOCUMENT_ROOT'].'/inc/i18n/'.$l.'.php');
  16. }
  17. if (!isset($LANG[$l][$key])) {
  18. $text=$key;
  19. } else {
  20. $text=$LANG[$l][$key];
  21. }
  22. array_shift($args);
  23. if (count($args)>1) {
  24. $args[0] = $text;
  25. return call_user_func_array("sprintf",$args);
  26. } else {
  27. return $text;
  28. }
  29. }
  30. }
  31. if (!function_exists('__')) {
  32. function __() {
  33. $args = func_get_args();
  34. array_unshift($args,$_SESSION['language']);
  35. return call_user_func_array("_translate",$args);
  36. }
  37. }
  38. ?>
  39. App.i18n.ARE_YOU_SURE = '<?php echo __('Are you sure?') ?>';
  40. App.Constants.UNLIM_VALUE = '<?php echo __('unlimited') ?>';