SettingsController.php 21 KB

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