Juno_okyo

Example Multi-languages

Aug 12th, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <?php
  2.  
  3. $languages = array(
  4.   'en' => array(
  5.     'title'           => 'J2TEAM Community',
  6.     'welcome_message' => 'Hello World!',
  7.     'intro_message'   => 'Here is an example of a multi-language website.'
  8.   ),
  9.   'vi' => array(
  10.     'title'           => 'J2TEAM Community',
  11.     'welcome_message' => 'Chào thế giới!',
  12.     'intro_message'   => 'Đây là một ví dụ về trang web sử dụng đa ngôn ngữ.'
  13.   )
  14. );
  15.  
  16. $user_language = isset($_GET['hl']) ? $_GET['hl'] : 'en'; // default: English
  17. $i18n = $languages[$user_language];
  18.  
  19. ?><!DOCTYPE html>
  20. <html>
  21. <head>
  22.   <meta charset="utf-8">
  23.   <meta http-equiv="X-UA-Compatible" content="IE=edge">
  24.   <title><?php echo $i18n['title']; ?></title>
  25. </head>
  26. <body>
  27.   <h1><?php echo $i18n['welcome_message']; ?></h1>
  28.   <p><?php echo $i18n['intro_message']; ?></p>
  29. </body>
  30. </html>
Add Comment
Please, Sign In to add comment