Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <?php
  2. return array(
  3. 'index' => 'Homepage',
  4. 'feedback' => 'Feedback'
  5. 'logout' => 'Logout from profile',
  6. )
  7. ?>
  8.  
  9. <?php
  10. return array(
  11. 'logout' => 'Выйти из профиля',
  12. )
  13. ?>
  14.  
  15. $lang = include('lang/en.php');
  16. if(isset($_GET['lang']))
  17. {
  18. $lang = array_merge($lang, include('lang/ru.php'));
  19. }
  20.  
  21. Array
  22. (
  23. [index] => Homepage
  24. [feedback] => Feedback
  25. [logout] => Выйти из профиля
  26. )
  27.  
  28. function __($name) {
  29. global $lang;
  30. return $lang[$name];
  31. }
  32.  
  33. ...
  34. <title><?=__('index')?></title>
  35. </head>
  36. <body>
  37. <?=__('feedback')?>
  38.  
  39. $file = file_get_contents("/path/to/file");
  40. $lines = explode('r', $file);
  41. foreach($lines as $line) $message[substr($line, 0, strpos($line, ','))] = substr($line, strpos($line, ','));
  42.  
  43. 1,The site is down.
  44. 2,Try again.
  45. 3,No soup for you!
  46. 4,Signs point to yes.
  47.  
  48. $defaultLang = array('Home','Logout',etc)
  49. $otherLang=array( 'ru' => array('Home_in_ru','logout_in_ru',etc);
  50.  
  51. echo translate('Home');
  52.  
  53. function translate($msg) {
  54. if ($_GET['lang']=='en')
  55. return $msg;
  56.  
  57. return $otherLang[$_GET['lang']][array_search($msg,$defaultLang)];
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement