1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Allow plugins to set short translation locale

This commit is contained in:
Chocobozzz 2021-04-20 16:14:09 +02:00
parent 24a792404c
commit 67baf6478a
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 10 additions and 8 deletions

View file

@ -23,6 +23,7 @@ import { PluginLibrary, RegisterServerAuthExternalOptions, RegisterServerAuthPas
import { ClientHtml } from '../client-html'
import { RegisterHelpers } from './register-helpers'
import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn'
import { getCompleteLocale } from '@shared/core-utils'
export interface RegisteredPlugin {
npmName: string
@ -444,10 +445,12 @@ export class PluginManager implements ServerHook {
const path = translationPaths[locale]
const json = await readJSON(join(this.getPluginPath(plugin.name, plugin.type), path))
if (!this.translations[locale]) this.translations[locale] = {}
this.translations[locale][npmName] = json
const completeLocale = getCompleteLocale(locale)
logger.info('Added locale %s of plugin %s.', locale, npmName)
if (!this.translations[completeLocale]) this.translations[completeLocale] = {}
this.translations[completeLocale][npmName] = json
logger.info('Added locale %s of plugin %s.', completeLocale, npmName)
}
}