SettingsController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. <?php
  2. namespace Typemill\Controllers;
  3. use \Symfony\Component\Yaml\Yaml;
  4. use Typemill\Models\Field;
  5. use Typemill\Models\Validation;
  6. use Typemill\Models\User;
  7. class SettingsController extends Controller
  8. {
  9. /*********************
  10. ** BASIC SETTINGS **
  11. *********************/
  12. public function showSettings($request, $response, $args)
  13. {
  14. $user = new User();
  15. $settings = $this->c->get('settings');
  16. $copyright = $this->getCopyright();
  17. $languages = $this->getLanguages();
  18. $locale = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
  19. $locale = $locale[0];
  20. $users = $user->getUsers();
  21. $route = $request->getAttribute('route');
  22. $this->render($response, 'settings/system.twig', array('settings' => $settings, 'copyright' => $copyright, 'languages' => $languages, 'locale' => $locale, 'users' => $users, 'route' => $route->getName() ));
  23. }
  24. public function saveSettings($request, $response, $args)
  25. {
  26. if($request->isPost())
  27. {
  28. $settings = \Typemill\Settings::getUserSettings();
  29. $params = $request->getParams();
  30. $newSettings = isset($params['settings']) ? $params['settings'] : false;
  31. $validate = new Validation();
  32. if($newSettings)
  33. {
  34. /* make sure only allowed fields are stored */
  35. $newSettings = array(
  36. 'title' => $newSettings['title'],
  37. 'author' => $newSettings['author'],
  38. 'copyright' => $newSettings['copyright'],
  39. 'year' => $newSettings['year'],
  40. 'statpage' => isset($newSettings['startpage']) ? true : false
  41. );
  42. $copyright = $this->getCopyright();
  43. $validate->settings($newSettings, $copyright, 'settings');
  44. }
  45. if(isset($_SESSION['errors']))
  46. {
  47. $this->c->flash->addMessage('error', 'Please correct the errors');
  48. return $response->withRedirect($this->c->router->pathFor('settings.show'));
  49. }
  50. /* store updated settings */
  51. \Typemill\Settings::updateSettings(array_merge($settings, $newSettings));
  52. $this->c->flash->addMessage('info', 'Settings are stored');
  53. return $response->withRedirect($this->c->router->pathFor('settings.show'));
  54. }
  55. }
  56. /*********************
  57. ** THEME SETTINGS **
  58. *********************/
  59. public function showThemes($request, $response, $args)
  60. {
  61. $userSettings = $this->c->get('settings');
  62. $themes = $this->getThemes();
  63. $themedata = array();
  64. foreach($themes as $themeName)
  65. {
  66. /* if theme is active, list it first */
  67. if($userSettings['theme'] == $themeName)
  68. {
  69. $themedata = array_merge(array($themeName => null), $themedata);
  70. }
  71. else
  72. {
  73. $themedata[$themeName] = null;
  74. }
  75. $themeSettings = \Typemill\Settings::getObjectSettings('themes', $themeName);
  76. if($themeSettings)
  77. {
  78. /* store them as default theme data with author, year, default settings and field-definitions */
  79. $themedata[$themeName] = $themeSettings;
  80. }
  81. if(isset($themeSettings['forms']['fields']))
  82. {
  83. $fields = $this->getFields($userSettings, 'themes', $themeName, $themeSettings);
  84. /* overwrite original theme form definitions with enhanced form objects */
  85. $themedata[$themeName]['forms']['fields'] = $fields;
  86. }
  87. /* add the preview image */
  88. $img = getcwd() . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $themeName . DIRECTORY_SEPARATOR . $themeName . '.jpg';
  89. $img = file_exists($img) ? $img : false;
  90. $themedata[$themeName]['img'] = $img;
  91. }
  92. /* add the users for navigation */
  93. $user = new User();
  94. $users = $user->getUsers();
  95. $route = $request->getAttribute('route');
  96. $this->render($response, 'settings/themes.twig', array('settings' => $userSettings, 'themes' => $themedata, 'users' => $users, 'route' => $route->getName() ));
  97. }
  98. public function showPlugins($request, $response, $args)
  99. {
  100. $userSettings = $this->c->get('settings');
  101. $plugins = array();
  102. $fields = array();
  103. /* iterate through the plugins in the stored user settings */
  104. foreach($userSettings['plugins'] as $pluginName => $pluginUserSettings)
  105. {
  106. /* add plugin to plugin Data, if active, set it first */
  107. /* if plugin is active, list it first */
  108. if($userSettings['plugins'][$pluginName]['active'] == true)
  109. {
  110. $plugins = array_merge(array($pluginName => null), $plugins);
  111. }
  112. else
  113. {
  114. $plugins[$pluginName] = Null;
  115. }
  116. /* Check if the user has deleted a plugin. Then delete it in the settings and store the updated settings. */
  117. if(!is_dir($userSettings['rootPath'] . 'plugins' . DIRECTORY_SEPARATOR . $pluginName))
  118. {
  119. /* remove the plugin settings and store updated settings */
  120. \Typemill\Settings::removePluginSettings($pluginName);
  121. continue;
  122. }
  123. /* load the original plugin definitions from the plugin folder (author, version and stuff) */
  124. $pluginOriginalSettings = \Typemill\Settings::getObjectSettings('plugins', $pluginName);
  125. if($pluginOriginalSettings)
  126. {
  127. /* store them as default plugin data with plugin author, plugin year, default settings and field-definitions */
  128. $plugins[$pluginName] = $pluginOriginalSettings;
  129. }
  130. /* check, if the plugin has been disabled in the form-session-data */
  131. if(isset($_SESSION['old']) && !isset($_SESSION['old'][$pluginName]['active']))
  132. {
  133. $plugins[$pluginName]['settings']['active'] = false;
  134. }
  135. /* if the plugin defines forms and fields, so that the user can edit the plugin settings in the frontend */
  136. if(isset($pluginOriginalSettings['forms']['fields']))
  137. {
  138. /* get all the fields and prefill them with the dafault-data, the user-data or old input data */
  139. $fields = $this->getFields($userSettings, 'plugins', $pluginName, $pluginOriginalSettings);
  140. /* overwrite original plugin form definitions with enhanced form objects */
  141. $plugins[$pluginName]['forms']['fields'] = $fields;
  142. }
  143. }
  144. $user = new User();
  145. $users = $user->getUsers();
  146. $route = $request->getAttribute('route');
  147. $this->render($response, 'settings/plugins.twig', array('settings' => $userSettings, 'plugins' => $plugins, 'users' => $users, 'route' => $route->getName() ));
  148. }
  149. private function getFields($userSettings, $objectType, $objectName, $objectSettings)
  150. {
  151. $fields = array();
  152. /* then iterate through the fields */
  153. foreach($objectSettings['forms']['fields'] as $fieldName => $fieldConfigs)
  154. {
  155. if($fieldConfigs['type'] == 'fieldset')
  156. {
  157. /* Create an array for the subsettings of the fieldset with the same structure and data as the original settings array */
  158. $subSettings = $objectSettings;
  159. $subSettings['forms'] = $fieldConfigs;
  160. $fieldset = array();
  161. $fieldset['type'] = 'fieldset';
  162. $fieldset['legend'] = $fieldConfigs['legend'];
  163. $fieldset['fields'] = $this->getFields($userSettings, $objectType, $objectName, $subSettings);
  164. $fields[] = $fieldset;
  165. }
  166. else
  167. {
  168. /* and create a new field object with the field name and the field configurations. */
  169. $field = new Field($fieldName, $fieldConfigs);
  170. /* you have to prefil the value for the field with default settings, user settings or old user-input from form */
  171. $userValue = false;
  172. /* first, add the default values from the original plugin or theme settings. Ignore checkboxes, otherwiese they might be always checked */
  173. if(isset($objectSettings['settings'][$fieldName]))
  174. {
  175. $userValue = $objectSettings['settings'][$fieldName];
  176. }
  177. /* now overwrite them with the local stored user settings */
  178. if(isset($userSettings[$objectType][$objectName][$fieldName]))
  179. {
  180. $userValue = $userSettings[$objectType][$objectName][$fieldName];
  181. }
  182. /* overwrite it with old input in form, if exists */
  183. if(isset($_SESSION['old'][$objectName][$fieldName]))
  184. {
  185. $userValue = $_SESSION['old'][$objectName][$fieldName];
  186. }
  187. /* now we have set the uservalue for the field. Prepopulate the field object with it now */
  188. if($field->getType() == "textarea")
  189. {
  190. if($userValue)
  191. {
  192. $field->setContent($userValue);
  193. }
  194. }
  195. elseif($field->getType() == "checkbox")
  196. {
  197. /* needs special treatment, because field does not exist in settings if unchecked by user */
  198. if(isset($userSettings[$objectType][$objectName][$fieldName]))
  199. {
  200. $field->setAttribute('checked', 'checked');
  201. }
  202. else
  203. {
  204. $field->unsetAttribute('checked');
  205. }
  206. }
  207. else
  208. {
  209. $field->setAttributeValue('value', $userValue);
  210. }
  211. /* add the field to the field-List with the plugin-name as key */
  212. $fields[] = $field;
  213. }
  214. }
  215. return $fields;
  216. }
  217. /*************************************
  218. ** SAVE THEME- AND PLUGIN-SETTINGS **
  219. *************************************/
  220. public function saveThemes($request, $response, $args)
  221. {
  222. if($request->isPost())
  223. {
  224. $userSettings = \Typemill\Settings::getUserSettings();
  225. $params = $request->getParams();
  226. $themeName = isset($params['theme']) ? $params['theme'] : false;
  227. $userInput = isset($params[$themeName]) ? $params[$themeName] : false;
  228. $validate = new Validation();
  229. /* set theme name and delete theme settings from user settings for the case, that the new theme has no settings */
  230. $userSettings['theme'] = $themeName;
  231. if($userInput)
  232. {
  233. /* validate the user-input */
  234. $this->validateInput('themes', $themeName, $userInput, $validate);
  235. /* set user input as theme settings */
  236. $userSettings['themes'][$themeName] = $userInput;
  237. }
  238. /* check for errors and redirect to path, if errors found */
  239. if(isset($_SESSION['errors']))
  240. {
  241. $this->c->flash->addMessage('error', 'Please correct the errors');
  242. return $response->withRedirect($this->c->router->pathFor('themes.show'));
  243. }
  244. /* store updated settings */
  245. \Typemill\Settings::updateSettings($userSettings);
  246. $this->c->flash->addMessage('info', 'Settings are stored');
  247. return $response->withRedirect($this->c->router->pathFor('themes.show'));
  248. }
  249. }
  250. public function savePlugins($request, $response, $args)
  251. {
  252. if($request->isPost())
  253. {
  254. $userSettings = \Typemill\Settings::getUserSettings();
  255. $pluginSettings = array();
  256. $userInput = $request->getParams();
  257. $validate = new Validation();
  258. /* use the stored user settings and iterate over all original plugin settings, so we do not forget any... */
  259. foreach($userSettings['plugins'] as $pluginName => $pluginUserSettings)
  260. {
  261. /* if there are no input-data for this plugin, then use the stored plugin settings */
  262. if(!isset($userInput[$pluginName]))
  263. {
  264. $pluginSettings[$pluginName] = $pluginUserSettings;
  265. }
  266. else
  267. {
  268. /* validate the user-input */
  269. $this->validateInput('plugins', $pluginName, $userInput[$pluginName], $validate);
  270. /* use the input data */
  271. $pluginSettings[$pluginName] = $userInput[$pluginName];
  272. }
  273. /* deactivate the plugin, if there is no active flag */
  274. if(!isset($userInput[$pluginName]['active']))
  275. {
  276. $pluginSettings[$pluginName]['active'] = false;
  277. }
  278. }
  279. if(isset($_SESSION['errors']))
  280. {
  281. $this->c->flash->addMessage('error', 'Please correct the errors below');
  282. }
  283. else
  284. {
  285. /* if everything is valid, add plugin settings to base settings again */
  286. $userSettings['plugins'] = $pluginSettings;
  287. /* store updated settings */
  288. \Typemill\Settings::updateSettings($userSettings);
  289. $this->c->flash->addMessage('info', 'Settings are stored');
  290. }
  291. return $response->withRedirect($this->c->router->pathFor('plugins.show'));
  292. }
  293. }
  294. private function validateInput($objectType, $objectName, $userInput, $validate)
  295. {
  296. /* fetch the original settings from the folder (plugin or theme) to get the field definitions */
  297. $originalSettings = \Typemill\Settings::getObjectSettings($objectType, $objectName);
  298. if(isset($originalSettings['forms']['fields']))
  299. {
  300. /* flaten the multi-dimensional array with fieldsets to a one-dimensional array */
  301. $originalFields = array();
  302. foreach($originalSettings['forms']['fields'] as $fieldName => $fieldValue)
  303. {
  304. if(isset($fieldValue['fields']))
  305. {
  306. foreach($fieldValue['fields'] as $subFieldName => $subFieldValue)
  307. {
  308. $originalFields[$subFieldName] = $subFieldValue;
  309. }
  310. }
  311. else
  312. {
  313. $originalFields[$fieldName] = $fieldValue;
  314. }
  315. }
  316. /* take the user input data and iterate over all fields and values */
  317. foreach($userInput as $fieldName => $fieldValue)
  318. {
  319. /* get the corresponding field definition from original plugin settings */
  320. $fieldDefinition = isset($originalFields[$fieldName]) ? $originalFields[$fieldName] : false;
  321. if($fieldDefinition)
  322. {
  323. /* validate user input for this field */
  324. $validate->objectField($fieldName, $fieldValue, $objectName, $fieldDefinition);
  325. }
  326. if(!$fieldDefinition && $fieldName != 'active')
  327. {
  328. $_SESSION['errors'][$objectName][$fieldName] = array('This field is not defined!');
  329. }
  330. }
  331. }
  332. }
  333. /***********************
  334. ** USER MANAGEMENT **
  335. ***********************/
  336. public function showUser($request, $response, $args)
  337. {
  338. if($_SESSION['role'] == 'editor' && $_SESSION['user'] !== $args['username'])
  339. {
  340. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $_SESSION['user']] ));
  341. }
  342. $validate = new Validation();
  343. if($validate->username($args['username']))
  344. {
  345. $user = new User();
  346. $users = $user->getUsers();
  347. $userrole = $user->getUserroles();
  348. $userdata = $user->getUser($args['username']);
  349. if($userdata)
  350. {
  351. return $this->render($response, 'settings/user.twig', array('users' => $users, 'userdata' => $userdata, 'userrole' => $userrole, 'username' => $args['username'] ));
  352. }
  353. }
  354. $this->c->flash->addMessage('error', 'User does not exists');
  355. return $response->withRedirect($this->c->router->pathFor('user.list'));
  356. }
  357. public function listUser($request, $response)
  358. {
  359. $user = new User();
  360. $users = $user->getUsers();
  361. $userdata = array();
  362. $route = $request->getAttribute('route');
  363. foreach($users as $username)
  364. {
  365. $userdata[] = $user->getUser($username);
  366. }
  367. $this->render($response, 'settings/userlist.twig', array('users' => $users, 'userdata' => $userdata, 'route' => $route->getName() ));
  368. }
  369. public function newUser($request, $response, $args)
  370. {
  371. $user = new User();
  372. $users = $user->getUsers();
  373. $userrole = $user->getUserroles();
  374. $route = $request->getAttribute('route');
  375. $this->render($response, 'settings/usernew.twig', array('users' => $users, 'userrole' => $userrole, 'route' => $route->getName() ));
  376. }
  377. public function createUser($request, $response, $args)
  378. {
  379. if($request->isPost())
  380. {
  381. $params = $request->getParams();
  382. $user = new User();
  383. $userroles = $user->getUserroles();
  384. $validate = new Validation();
  385. if($validate->newUser($params, $userroles))
  386. {
  387. $userdata = array('username' => $params['username'], 'email' => $params['email'], 'userrole' => $params['userrole'], 'password' => $params['password']);
  388. $user->createUser($userdata);
  389. $this->c->flash->addMessage('info', 'Welcome, there is a new user!');
  390. return $response->withRedirect($this->c->router->pathFor('user.list'));
  391. }
  392. $this->c->flash->addMessage('error', 'Please correct your input');
  393. return $response->withRedirect($this->c->router->pathFor('user.new'));
  394. }
  395. }
  396. public function updateUser($request, $response, $args)
  397. {
  398. if($request->isPost())
  399. {
  400. $params = $request->getParams();
  401. $user = new User();
  402. $userroles = $user->getUserroles();
  403. $validate = new Validation();
  404. /* non admins have different update rights */
  405. if($_SESSION['role'] !== 'administrator')
  406. {
  407. /* if an editor tries to update other userdata than its own */
  408. if($_SESSION['user'] !== $params['username'])
  409. {
  410. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $_SESSION['user']] ));
  411. }
  412. /* non admins cannot change his userrole */
  413. $params['userrole'] = $_SESSION['role'];
  414. }
  415. if($validate->existingUser($params, $userroles))
  416. {
  417. $userdata = array('username' => $params['username'], 'email' => $params['email'], 'userrole' => $params['userrole']);
  418. if(empty($params['password']) AND empty($params['newpassword']))
  419. {
  420. $user->updateUser($userdata);
  421. $this->c->flash->addMessage('info', 'Saved all changes');
  422. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $params['username']]));
  423. }
  424. elseif($validate->newPassword($params))
  425. {
  426. $userdata['password'] = $params['newpassword'];
  427. $user->updateUser($userdata);
  428. $this->c->flash->addMessage('info', 'Saved all changes');
  429. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $params['username']]));
  430. }
  431. }
  432. $this->c->flash->addMessage('error', 'Please correct your input');
  433. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $params['username']]));
  434. }
  435. }
  436. public function deleteUser($request, $response, $args)
  437. {
  438. if($request->isPost())
  439. {
  440. $params = $request->getParams();
  441. $validate = new Validation();
  442. $user = new User();
  443. /* non admins have different update rights */
  444. if($_SESSION['role'] !== 'administrator')
  445. {
  446. /* if an editor tries to delete other user than its own */
  447. if($_SESSION['user'] !== $params['username'])
  448. {
  449. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $_SESSION['user']] ));
  450. }
  451. }
  452. if($validate->username($params['username']))
  453. {
  454. $user->deleteUser($params['username']);
  455. $this->c->flash->addMessage('info', 'Say goodbye, the user is gone!');
  456. return $response->withRedirect($this->c->router->pathFor('user.list'));
  457. }
  458. $this->c->flash->addMessage('error', 'Ups, we did not find that user');
  459. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $params['username']]));
  460. }
  461. }
  462. private function getThemes()
  463. {
  464. $themeFolder = $this->c->get('settings')['rootPath'] . $this->c->get('settings')['themeFolder'];
  465. $themeFolderC = scandir($themeFolder);
  466. $themes = array();
  467. foreach ($themeFolderC as $key => $theme)
  468. {
  469. if (!in_array($theme, array(".","..")))
  470. {
  471. if (is_dir($themeFolder . DIRECTORY_SEPARATOR . $theme))
  472. {
  473. $themes[] = $theme;
  474. }
  475. }
  476. }
  477. return $themes;
  478. }
  479. private function getCopyright()
  480. {
  481. return array(
  482. "©",
  483. "CC-BY",
  484. "CC-BY-NC",
  485. "CC-BY-NC-ND",
  486. "CC-BY-NC-SA",
  487. "CC-BY-ND",
  488. "CC-BY-SA",
  489. "None"
  490. );
  491. }
  492. private function getLanguages()
  493. {
  494. return array(
  495. 'ab' => 'Abkhazian',
  496. 'aa' => 'Afar',
  497. 'af' => 'Afrikaans',
  498. 'ak' => 'Akan',
  499. 'sq' => 'Albanian',
  500. 'am' => 'Amharic',
  501. 'ar' => 'Arabic',
  502. 'an' => 'Aragonese',
  503. 'hy' => 'Armenian',
  504. 'as' => 'Assamese',
  505. 'av' => 'Avaric',
  506. 'ae' => 'Avestan',
  507. 'ay' => 'Aymara',
  508. 'az' => 'Azerbaijani',
  509. 'bm' => 'Bambara',
  510. 'ba' => 'Bashkir',
  511. 'eu' => 'Basque',
  512. 'be' => 'Belarusian',
  513. 'bn' => 'Bengali',
  514. 'bh' => 'Bihari languages',
  515. 'bi' => 'Bislama',
  516. 'bs' => 'Bosnian',
  517. 'br' => 'Breton',
  518. 'bg' => 'Bulgarian',
  519. 'my' => 'Burmese',
  520. 'ca' => 'Catalan, Valencian',
  521. 'km' => 'Central Khmer',
  522. 'ch' => 'Chamorro',
  523. 'ce' => 'Chechen',
  524. 'ny' => 'Chichewa, Chewa, Nyanja',
  525. 'zh' => 'Chinese',
  526. 'cu' => 'Church Slavonic, Old Bulgarian, Old Church Slavonic',
  527. 'cv' => 'Chuvash',
  528. 'kw' => 'Cornish',
  529. 'co' => 'Corsican',
  530. 'cr' => 'Cree',
  531. 'hr' => 'Croatian',
  532. 'cs' => 'Czech',
  533. 'da' => 'Danish',
  534. 'dv' => 'Divehi, Dhivehi, Maldivian',
  535. 'nl' => 'Dutch, Flemish',
  536. 'dz' => 'Dzongkha',
  537. 'en' => 'English',
  538. 'eo' => 'Esperanto',
  539. 'et' => 'Estonian',
  540. 'ee' => 'Ewe',
  541. 'fo' => 'Faroese',
  542. 'fj' => 'Fijian',
  543. 'fi' => 'Finnish',
  544. 'fr' => 'French',
  545. 'ff' => 'Fulah',
  546. 'gd' => 'Gaelic, Scottish Gaelic',
  547. 'gl' => 'Galician',
  548. 'lg' => 'Ganda',
  549. 'ka' => 'Georgian',
  550. 'de' => 'German',
  551. 'ki' => 'Gikuyu, Kikuyu',
  552. 'el' => 'Greek (Modern)',
  553. 'kl' => 'Greenlandic, Kalaallisut',
  554. 'gn' => 'Guarani',
  555. 'gu' => 'Gujarati',
  556. 'ht' => 'Haitian, Haitian Creole',
  557. 'ha' => 'Hausa',
  558. 'he' => 'Hebrew',
  559. 'hz' => 'Herero',
  560. 'hi' => 'Hindi',
  561. 'ho' => 'Hiri Motu',
  562. 'hu' => 'Hungarian',
  563. 'is' => 'Icelandic',
  564. 'io' => 'Ido',
  565. 'ig' => 'Igbo',
  566. 'id' => 'Indonesian',
  567. 'ia' => 'Interlingua (International Auxiliary Language Association)',
  568. 'ie' => 'Interlingue',
  569. 'iu' => 'Inuktitut',
  570. 'ik' => 'Inupiaq',
  571. 'ga' => 'Irish',
  572. 'it' => 'Italian',
  573. 'ja' => 'Japanese',
  574. 'jv' => 'Javanese',
  575. 'kn' => 'Kannada',
  576. 'kr' => 'Kanuri',
  577. 'ks' => 'Kashmiri',
  578. 'kk' => 'Kazakh',
  579. 'rw' => 'Kinyarwanda',
  580. 'kv' => 'Komi',
  581. 'kg' => 'Kongo',
  582. 'ko' => 'Korean',
  583. 'kj' => 'Kwanyama, Kuanyama',
  584. 'ku' => 'Kurdish',
  585. 'ky' => 'Kyrgyz',
  586. 'lo' => 'Lao',
  587. 'la' => 'Latin',
  588. 'lv' => 'Latvian',
  589. 'lb' => 'Letzeburgesch, Luxembourgish',
  590. 'li' => 'Limburgish, Limburgan, Limburger',
  591. 'ln' => 'Lingala',
  592. 'lt' => 'Lithuanian',
  593. 'lu' => 'Luba-Katanga',
  594. 'mk' => 'Macedonian',
  595. 'mg' => 'Malagasy',
  596. 'ms' => 'Malay',
  597. 'ml' => 'Malayalam',
  598. 'mt' => 'Maltese',
  599. 'gv' => 'Manx',
  600. 'mi' => 'Maori',
  601. 'mr' => 'Marathi',
  602. 'mh' => 'Marshallese',
  603. 'ro' => 'Moldovan, Moldavian, Romanian',
  604. 'mn' => 'Mongolian',
  605. 'na' => 'Nauru',
  606. 'nv' => 'Navajo, Navaho',
  607. 'nd' => 'Northern Ndebele',
  608. 'ng' => 'Ndonga',
  609. 'ne' => 'Nepali',
  610. 'se' => 'Northern Sami',
  611. 'no' => 'Norwegian',
  612. 'nb' => 'Norwegian Bokmål',
  613. 'nn' => 'Norwegian Nynorsk',
  614. 'ii' => 'Nuosu, Sichuan Yi',
  615. 'oc' => 'Occitan (post 1500)',
  616. 'oj' => 'Ojibwa',
  617. 'or' => 'Oriya',
  618. 'om' => 'Oromo',
  619. 'os' => 'Ossetian, Ossetic',
  620. 'pi' => 'Pali',
  621. 'pa' => 'Panjabi, Punjabi',
  622. 'ps' => 'Pashto, Pushto',
  623. 'fa' => 'Persian',
  624. 'pl' => 'Polish',
  625. 'pt' => 'Portuguese',
  626. 'qu' => 'Quechua',
  627. 'rm' => 'Romansh',
  628. 'rn' => 'Rundi',
  629. 'ru' => 'Russian',
  630. 'sm' => 'Samoan',
  631. 'sg' => 'Sango',
  632. 'sa' => 'Sanskrit',
  633. 'sc' => 'Sardinian',
  634. 'sr' => 'Serbian',
  635. 'sn' => 'Shona',
  636. 'sd' => 'Sindhi',
  637. 'si' => 'Sinhala, Sinhalese',
  638. 'sk' => 'Slovak',
  639. 'sl' => 'Slovenian',
  640. 'so' => 'Somali',
  641. 'st' => 'Sotho, Southern',
  642. 'nr' => 'South Ndebele',
  643. 'es' => 'Spanish, Castilian',
  644. 'su' => 'Sundanese',
  645. 'sw' => 'Swahili',
  646. 'ss' => 'Swati',
  647. 'sv' => 'Swedish',
  648. 'tl' => 'Tagalog',
  649. 'ty' => 'Tahitian',
  650. 'tg' => 'Tajik',
  651. 'ta' => 'Tamil',
  652. 'tt' => 'Tatar',
  653. 'te' => 'Telugu',
  654. 'th' => 'Thai',
  655. 'bo' => 'Tibetan',
  656. 'ti' => 'Tigrinya',
  657. 'to' => 'Tonga (Tonga Islands)',
  658. 'ts' => 'Tsonga',
  659. 'tn' => 'Tswana',
  660. 'tr' => 'Turkish',
  661. 'tk' => 'Turkmen',
  662. 'tw' => 'Twi',
  663. 'ug' => 'Uighur, Uyghur',
  664. 'uk' => 'Ukrainian',
  665. 'ur' => 'Urdu',
  666. 'uz' => 'Uzbek',
  667. 've' => 'Venda',
  668. 'vi' => 'Vietnamese',
  669. 'vo' => 'Volap_k',
  670. 'wa' => 'Walloon',
  671. 'cy' => 'Welsh',
  672. 'fy' => 'Western Frisian',
  673. 'wo' => 'Wolof',
  674. 'xh' => 'Xhosa',
  675. 'yi' => 'Yiddish',
  676. 'yo' => 'Yoruba',
  677. 'za' => 'Zhuang, Chuang',
  678. 'zu' => 'Zulu'
  679. );
  680. }
  681. }