DictApi.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace App\Http\Api;
  3. use App\Models\DictInfo;
  4. class DictApi
  5. {
  6. public static function langOrder(string $lang)
  7. {
  8. switch ($lang) {
  9. case 'zh':
  10. $output = ['zh', 'jp', 'en', 'my'];
  11. break;
  12. case 'en':
  13. $output = ['en', 'my'];
  14. break;
  15. case 'my':
  16. $output = ['my', 'en'];
  17. break;
  18. default:
  19. $output = [$lang, 'en', 'my'];
  20. break;
  21. }
  22. $output[] = 'others';
  23. return $output;
  24. }
  25. public static function dictOrder($lang)
  26. {
  27. $output = [];
  28. switch ($lang) {
  29. case 'zh':
  30. $output = [
  31. '0d79e8e8-1430-4c99-a0f1-b74f2b4b26d8', /* 《巴汉词典》增订 */
  32. 'f364d3dc-b611-471b-9a4f-531286b8c2c3', /* 《巴汉词典》Mahāñāṇo Bhikkhu编著 */
  33. '0e4dc5c8-a228-4693-92ba-7d42918d8a91', /* 汉译パーリ语辞典-黃秉榮 */
  34. '6aa9ec8b-bba4-4bcd-abd2-9eae015bad2b', /* 汉译パーリ语辞典-李瑩 */
  35. 'eb99f8b4-c3e5-43af-9102-6a93fcb97db6', /* パーリ语辞典--勘误表 */
  36. ];
  37. break;
  38. case 'jp':
  39. $output = [
  40. '91d3ec93-3811-4973-8d84-ced99179a0aa', /* パーリ语辞典 */
  41. '6d6c6812-75e7-457d-874f-5b049ad4b6de', /* パーリ语辞典-增补 */
  42. ];
  43. break;
  44. case 'en':
  45. $output = [
  46. 'c6e70507-4a14-4687-8b70-2d0c7eb0cf21', /* Concise P-E Dict */
  47. '6afb8c05-5cbe-422e-b691-0d4507450cb7', /* PTS P-E dictionary */
  48. ];
  49. break;
  50. case 'my':
  51. $output = [
  52. 'e740ef40-26d7-416e-96c2-925d6650ac6b', /* Tipiṭaka Pāḷi-Myanmar */
  53. 'beb45062-7c20-4047-bcd4-1f636ba443d1', /* U Hau Sein’s Pāḷi-Myanmar Dictionary */
  54. '1e299ccb-4fc4-487d-8d72-08f63d84c809', /* Pali Roots Dictionary */
  55. '6f9caea1-17fa-41f1-92e5-bd8e6e70e1d7', /* U Hau Sein’s Pāḷi-Myanmar */
  56. ];
  57. break;
  58. case 'vi':
  59. $output = [
  60. '23f67523-fa03-48d9-9dda-ede80d578dd2', /* Pali Viet Dictionary */
  61. '4ac8a0d5-9c6f-4b9f-983d-84288d47f993', /* Pali Viet Abhi-Terms */
  62. '7c7ee287-35ba-4cf3-b87b-30f1fa6e57c9', /* Pali Viet Vinaya Terms */
  63. ];
  64. break;
  65. default:
  66. $output = [];
  67. break;
  68. }
  69. $output[] = 'others';
  70. return $output;
  71. }
  72. public static function getSysDict($name)
  73. {
  74. $dict_info = DictInfo::where('name', $name)
  75. ->where('owner_id', config('mint.admin.root_uuid'))
  76. ->first();
  77. if (! $dict_info) {
  78. return false;
  79. } else {
  80. return $dict_info->id;
  81. }
  82. }
  83. }