aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/constants.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-04-23 14:39:52 +0200
committerChocobozzz <me@florianbigard.com>2018-04-23 14:39:52 +0200
commit9d3ef9fe052ed29bd67566754cb28662bd122234 (patch)
tree7b704dbc0b2c8b4ca18bef2409d640d0019c3d0a /server/initializers/constants.ts
parent2a2c19dfef7a9aa313c6ca0798f271c9a63449a9 (diff)
downloadPeerTube-9d3ef9fe052ed29bd67566754cb28662bd122234.tar.gz
PeerTube-9d3ef9fe052ed29bd67566754cb28662bd122234.tar.zst
PeerTube-9d3ef9fe052ed29bd67566754cb28662bd122234.zip
Use ISO 639 for languages
Diffstat (limited to 'server/initializers/constants.ts')
-rw-r--r--server/initializers/constants.ts70
1 files changed, 37 insertions, 33 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index d1915586a..9c9c3afc0 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -13,7 +13,7 @@ let config: IConfig = require('config')
13 13
14// --------------------------------------------------------------------------- 14// ---------------------------------------------------------------------------
15 15
16const LAST_MIGRATION_VERSION = 205 16const LAST_MIGRATION_VERSION = 210
17 17
18// --------------------------------------------------------------------------- 18// ---------------------------------------------------------------------------
19 19
@@ -196,6 +196,7 @@ const CONSTRAINTS_FIELDS = {
196 }, 196 },
197 VIDEOS: { 197 VIDEOS: {
198 NAME: { min: 3, max: 120 }, // Length 198 NAME: { min: 3, max: 120 }, // Length
199 LANGUAGE: { min: 1, max: 10 }, // Length
199 TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length 200 TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length
200 DESCRIPTION: { min: 3, max: 10000 }, // Length 201 DESCRIPTION: { min: 3, max: 10000 }, // Length
201 SUPPORT: { min: 3, max: 300 }, // Length 202 SUPPORT: { min: 3, max: 300 }, // Length
@@ -291,38 +292,7 @@ const VIDEO_LICENCES = {
291 7: 'Public Domain Dedication' 292 7: 'Public Domain Dedication'
292} 293}
293 294
294// See https://en.wikipedia.org/wiki/List_of_languages_by_number_of_native_speakers#Nationalencyklopedin 295const VIDEO_LANGUAGES = buildLanguages()
295const VIDEO_LANGUAGES = {
296 1: 'English',
297 2: 'Spanish',
298 3: 'Mandarin',
299 4: 'Hindi',
300 5: 'Arabic',
301 6: 'Portuguese',
302 7: 'Bengali',
303 8: 'Russian',
304 9: 'Japanese',
305 10: 'Punjabi',
306 11: 'German',
307 12: 'Korean',
308 13: 'French',
309 14: 'Italian',
310 1000: 'Sign Language',
311 1001: 'American Sign Language',
312 1002: 'Arab Sign Language',
313 1003: 'British Sign Language',
314 1004: 'Brazilian Sign Language',
315 1005: 'Chinese Sign Language',
316 1006: 'Czech Sign Language',
317 1007: 'Danish Sign Language',
318 1008: 'French Sign Language',
319 1009: 'German Sign Language',
320 1010: 'Indo-Pakistani Sign Language',
321 1011: 'Japanese Sign Language',
322 1012: 'South African Sign Language',
323 1013: 'Swedish Sign Language',
324 1014: 'Russian Sign Language'
325}
326 296
327const VIDEO_PRIVACIES = { 297const VIDEO_PRIVACIES = {
328 [VideoPrivacy.PUBLIC]: 'Public', 298 [VideoPrivacy.PUBLIC]: 'Public',
@@ -521,6 +491,40 @@ function updateWebserverConfig () {
521 CONFIG.WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP) 491 CONFIG.WEBSERVER.HOST = sanitizeHost(CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT, REMOTE_SCHEME.HTTP)
522} 492}
523 493
494function buildLanguages () {
495 const iso639 = require('iso-639-3')
496
497 const languages: { [ id: string ]: string } = {}
498
499 const signLanguages = [
500 'sgn', // Sign languages (macro language)
501 'ase', // American
502 'sdl', // Arabian
503 'bfi', // British
504 'bzs', // Brazilian
505 'csl', // Chinese
506 'cse', // Czech
507 'dsl', // Danish
508 'fsl', // French
509 'gsg', // German
510 'pks', // Pakistan
511 'jsl', // Japanese
512 'sfs', // South African
513 'swl', // Swedish
514 'rsl' // Russian
515 ]
516
517 // Only add ISO639-1 languages and some sign languages (ISO639-3)
518 iso639
519 .filter(l => {
520 return (l.iso6391 !== null && l.type === 'living') ||
521 signLanguages.indexOf(l.iso6393) !== -1
522 })
523 .forEach(l => languages[l.iso6391 || l.iso6393] = l.name)
524
525 return languages
526}
527
524export function reloadConfig () { 528export function reloadConfig () {
525 529
526 function directory () { 530 function directory () {