SettingsController.php 21 KB

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