SettingsController.php 21 KB

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