ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

create-custom-files.ts 5.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import { readJsonSync, writeJSON } from 'fs-extra/esm'
  2. import { join } from 'path'
  3. import { I18N_LOCALES, USER_ROLE_LABELS } from '@peertube/peertube-core-utils'
  4. import { root } from '@peertube/peertube-node-utils'
  5. import {
  6. ABUSE_STATES,
  7. buildLanguages,
  8. RUNNER_JOB_STATES,
  9. USER_EXPORT_STATES,
  10. USER_REGISTRATION_STATES,
  11. VIDEO_CATEGORIES,
  12. VIDEO_CHANNEL_SYNC_STATE,
  13. VIDEO_IMPORT_STATES,
  14. VIDEO_LICENCES,
  15. VIDEO_PLAYLIST_PRIVACIES,
  16. VIDEO_PLAYLIST_TYPES,
  17. VIDEO_PRIVACIES,
  18. USER_IMPORT_STATES,
  19. VIDEO_STATES
  20. } from '@peertube/peertube-server/core/initializers/constants.js'
  21. const videojs = readJsonSync(join(root(), 'client', 'src', 'locale', 'videojs.en-US.json'))
  22. const playerKeys = {
  23. 'Quality': 'Quality',
  24. 'Auto': 'Auto',
  25. 'Speed': 'Speed',
  26. 'Subtitles/CC': 'Subtitles/CC',
  27. 'peers': 'peers',
  28. 'peer': 'peer',
  29. 'Go to the video page': 'Go to the video page',
  30. 'Settings': 'Settings',
  31. 'Watching this video may reveal your IP address to others.': 'Watching this video may reveal your IP address to others.',
  32. 'Copy the video URL': 'Copy the video URL',
  33. 'Copy the video URL at the current time': 'Copy the video URL at the current time',
  34. 'Copy embed code': 'Copy embed code',
  35. 'Copy magnet URI': 'Copy magnet URI',
  36. 'Total downloaded: ': 'Total downloaded: ',
  37. 'Total uploaded: ': 'Total uploaded: ',
  38. 'From servers: ': 'From servers: ',
  39. 'From peers: ': 'From peers: ',
  40. 'Normal mode': 'Normal mode',
  41. 'Stats for nerds': 'Stats for nerds',
  42. 'Theater mode': 'Theater mode',
  43. 'Video UUID': 'Video UUID',
  44. 'Viewport / Frames': 'Viewport / Frames',
  45. 'Resolution': 'Resolution',
  46. 'Volume': 'Volume',
  47. 'Codecs': 'Codecs',
  48. 'Color': 'Color',
  49. 'Go back to the live': 'Go back to the live',
  50. 'Connection Speed': 'Connection Speed',
  51. 'Network Activity': 'Network Activity',
  52. 'Total Transfered': 'Total Transfered',
  53. 'Download Breakdown': 'Download Breakdown',
  54. 'Buffer Progress': 'Buffer Progress',
  55. 'Buffer State': 'Buffer State',
  56. 'Live Latency': 'Live Latency',
  57. 'P2P': 'P2P',
  58. '{1} seconds': '{1} seconds',
  59. 'enabled': 'enabled',
  60. 'Playlist: {1}': 'Playlist: {1}',
  61. 'disabled': 'disabled',
  62. ' off': ' off',
  63. 'Player mode': 'Player mode',
  64. 'Play in loop': 'Play in loop',
  65. 'This live has not started yet.': 'This live has not started yet.',
  66. 'This live has ended.': 'This live has ended.',
  67. 'The video failed to play, will try to fast forward.': 'The video failed to play, will try to fast forward.',
  68. '{1} / {2} dropped of {3}': '{1} / {2} dropped of {3}',
  69. ' (muted)': ' (muted)',
  70. '{1} from servers · {2} from peers': '{1} from servers · {2} from peers',
  71. 'Previous video': 'Previous video',
  72. 'Video page (new window)': 'Video page (new window)',
  73. 'Next video': 'Next video',
  74. 'This video is password protected': 'This video is password protected',
  75. 'You need a password to watch this video.': 'You need a password to watch this video.',
  76. 'Incorrect password, please enter a correct password': 'Incorrect password, please enter a correct password',
  77. 'Cancel': 'Cancel',
  78. 'Up Next': 'Up Next',
  79. 'Autoplay is suspended': 'Autoplay is suspended',
  80. '{1} (from edge: {2})': '{1} (from edge: {2})',
  81. 'Disable subtitles': 'Disable subtitles',
  82. 'Enable {1} subtitle': 'Enable {1} subtitle',
  83. '{1} (auto-generated)': '{1} (auto-generated)',
  84. 'Go back': 'Go back'
  85. }
  86. Object.assign(playerKeys, videojs)
  87. // Server keys
  88. const serverKeys: any = {}
  89. Object.values(VIDEO_CATEGORIES)
  90. .concat(Object.values(VIDEO_LICENCES))
  91. .concat(Object.values(VIDEO_PRIVACIES))
  92. .concat(Object.values(VIDEO_STATES))
  93. .concat(Object.values(VIDEO_IMPORT_STATES))
  94. .concat(Object.values(VIDEO_PLAYLIST_PRIVACIES))
  95. .concat(Object.values(VIDEO_PLAYLIST_TYPES))
  96. .concat(Object.values(USER_ROLE_LABELS))
  97. .concat(Object.values(VIDEO_CHANNEL_SYNC_STATE))
  98. .concat(Object.values(ABUSE_STATES))
  99. .concat(Object.values(USER_REGISTRATION_STATES))
  100. .concat(Object.values(RUNNER_JOB_STATES))
  101. .concat(Object.values(USER_EXPORT_STATES))
  102. .concat(Object.values(USER_IMPORT_STATES))
  103. .concat([
  104. 'This video does not exist.',
  105. 'We cannot fetch the video. Please try again later.',
  106. 'Sorry',
  107. 'This video is not available because the remote instance is not responding.',
  108. 'This playlist does not exist',
  109. 'We cannot fetch the playlist. Please try again later.',
  110. 'Playlist: {1}',
  111. 'By {1}',
  112. 'Unavailable video'
  113. ])
  114. .forEach(v => { serverKeys[v] = v })
  115. // More keys
  116. Object.assign(serverKeys, {
  117. Unknown: 'Unknown'
  118. })
  119. // ISO 639 keys
  120. const languageKeys: any = {}
  121. const languages = buildLanguages()
  122. Object.keys(languages).forEach(k => { languageKeys[languages[k]] = languages[k] })
  123. Object.assign(serverKeys, languageKeys)
  124. writeAll().catch(err => {
  125. console.error(err)
  126. process.exit(-1)
  127. })
  128. async function writeAll () {
  129. const localePath = join(root(), 'client', 'src', 'locale')
  130. await writeJSON(join(localePath, 'player.en-US.json'), playerKeys, { spaces: 4 })
  131. await writeJSON(join(localePath, 'server.en-US.json'), serverKeys, { spaces: 4 })
  132. for (const key of Object.keys(I18N_LOCALES)) {
  133. const playerJsonPath = join(localePath, `player.${key}.json`)
  134. const translatedPlayer = readJsonSync(playerJsonPath)
  135. const newTranslatedPlayer = Object.assign({}, playerKeys, translatedPlayer)
  136. await writeJSON(playerJsonPath, newTranslatedPlayer, { spaces: 4 })
  137. const serverJsonPath = join(localePath, `server.${key}.json`)
  138. const translatedServer = readJsonSync(serverJsonPath)
  139. const newTranslatedServer = Object.assign({}, serverKeys, translatedServer)
  140. await writeJSON(serverJsonPath, newTranslatedServer, { spaces: 4 })
  141. }
  142. }