+ getVideoPrivacies () {
+ return this.videoPrivacies
+ }
+
+ getAbout () {
+ return this.http.get<About>(ServerService.BASE_CONFIG_URL + '/about')
+ }
+
+ private loadVideoAttributeEnum (
+ attributeName: 'categories' | 'licences' | 'languages' | 'privacies',
+ hashToPopulate: VideoConstant<number | string>[],
+ notifier: ReplaySubject<boolean>,
+ sort = false
+ ) {
+ this.localeObservable
+ .pipe(
+ switchMap(translations => {
+ return this.http.get(ServerService.BASE_VIDEO_URL + attributeName)
+ .pipe(map(data => ({ data, translations })))
+ })
+ )
+ .subscribe(({ data, translations }) => {
+ Object.keys(data)
+ .forEach(dataKey => {
+ const label = data[ dataKey ]
+
+ hashToPopulate.push({
+ id: dataKey,
+ label: peertubeTranslate(label, translations)
+ })
+ })
+
+ if (sort === true) {
+ hashToPopulate.sort((a, b) => {
+ if (a.label < b.label) return -1
+ if (a.label === b.label) return 0
+ return 1
+ })
+ }
+
+ notifier.next(true)
+ })
+ }
+
+ private loadServerLocale () {
+ const completeLocale = isOnDevLocale() ? getDevLocale() : getCompleteLocale(this.localeId)
+
+ // Default locale, nothing to translate
+ if (isDefaultLocale(completeLocale)) {
+ this.localeObservable = of({}).pipe(share())
+ return
+ }
+
+ this.localeObservable = this.http
+ .get(ServerService.BASE_LOCALE_URL + completeLocale + '/server.json')
+ .pipe(share())
+ }
+
+ private saveConfigLocally (config: ServerConfig) {
+ peertubeLocalStorage.setItem(ServerService.CONFIG_LOCAL_STORAGE_KEY, JSON.stringify(config))
+ }
+
+ private loadConfigLocally () {
+ const configString = peertubeLocalStorage.getItem(ServerService.CONFIG_LOCAL_STORAGE_KEY)
+
+ if (configString) {
+ try {
+ const parsed = JSON.parse(configString)
+ Object.assign(this.config, parsed)
+ } catch (err) {
+ console.error('Cannot parse config saved in local storage.', err)
+ }
+ }