diff options
-rw-r--r-- | server/lib/plugins/plugin-manager.ts | 9 | ||||
-rw-r--r-- | shared/core-utils/i18n/i18n.ts | 6 | ||||
-rw-r--r-- | support/doc/plugins/guide.md | 3 |
3 files changed, 10 insertions, 8 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts index f3766ffa8..ae05af721 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/lib/plugins/plugin-manager.ts | |||
@@ -23,6 +23,7 @@ import { PluginLibrary, RegisterServerAuthExternalOptions, RegisterServerAuthPas | |||
23 | import { ClientHtml } from '../client-html' | 23 | import { ClientHtml } from '../client-html' |
24 | import { RegisterHelpers } from './register-helpers' | 24 | import { RegisterHelpers } from './register-helpers' |
25 | import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn' | 25 | import { installNpmPlugin, installNpmPluginFromDisk, removeNpmPlugin } from './yarn' |
26 | import { getCompleteLocale } from '@shared/core-utils' | ||
26 | 27 | ||
27 | export interface RegisteredPlugin { | 28 | export interface RegisteredPlugin { |
28 | npmName: string | 29 | npmName: string |
@@ -444,10 +445,12 @@ export class PluginManager implements ServerHook { | |||
444 | const path = translationPaths[locale] | 445 | const path = translationPaths[locale] |
445 | const json = await readJSON(join(this.getPluginPath(plugin.name, plugin.type), path)) | 446 | const json = await readJSON(join(this.getPluginPath(plugin.name, plugin.type), path)) |
446 | 447 | ||
447 | if (!this.translations[locale]) this.translations[locale] = {} | 448 | const completeLocale = getCompleteLocale(locale) |
448 | this.translations[locale][npmName] = json | ||
449 | 449 | ||
450 | logger.info('Added locale %s of plugin %s.', locale, npmName) | 450 | if (!this.translations[completeLocale]) this.translations[completeLocale] = {} |
451 | this.translations[completeLocale][npmName] = json | ||
452 | |||
453 | logger.info('Added locale %s of plugin %s.', completeLocale, npmName) | ||
451 | } | 454 | } |
452 | } | 455 | } |
453 | 456 | ||
diff --git a/shared/core-utils/i18n/i18n.ts b/shared/core-utils/i18n/i18n.ts index a342cb3f8..f27de20f1 100644 --- a/shared/core-utils/i18n/i18n.ts +++ b/shared/core-utils/i18n/i18n.ts | |||
@@ -75,9 +75,9 @@ export function isDefaultLocale (locale: string) { | |||
75 | } | 75 | } |
76 | 76 | ||
77 | export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) { | 77 | export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) { |
78 | // FIXME: remove disable rule when the client is upgraded to typescript 3.7 | 78 | if (!translations || !translations[str]) return str |
79 | // eslint-disable-next-line | 79 | |
80 | return translations && translations[str] ? translations[str] : str | 80 | return translations[str] |
81 | } | 81 | } |
82 | 82 | ||
83 | const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l) | 83 | const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l) |
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md index 17c681afd..5b5a3065d 100644 --- a/support/doc/plugins/guide.md +++ b/support/doc/plugins/guide.md | |||
@@ -744,7 +744,7 @@ If you want to translate strings of your plugin (like labels of your registered | |||
744 | { | 744 | { |
745 | ..., | 745 | ..., |
746 | "translations": { | 746 | "translations": { |
747 | "fr-FR": "./languages/fr.json", | 747 | "fr": "./languages/fr.json", |
748 | "pt-BR": "./languages/pt-BR.json" | 748 | "pt-BR": "./languages/pt-BR.json" |
749 | }, | 749 | }, |
750 | ... | 750 | ... |
@@ -752,7 +752,6 @@ If you want to translate strings of your plugin (like labels of your registered | |||
752 | ``` | 752 | ``` |
753 | 753 | ||
754 | The key should be one of the locales defined in [i18n.ts](https://github.com/Chocobozzz/PeerTube/blob/develop/shared/models/i18n/i18n.ts). | 754 | The key should be one of the locales defined in [i18n.ts](https://github.com/Chocobozzz/PeerTube/blob/develop/shared/models/i18n/i18n.ts). |
755 | You **must** use the complete locales (`fr-FR` instead of `fr`). | ||
756 | 755 | ||
757 | Translation files are just objects, with the english sentence as the key and the translation as the value. | 756 | Translation files are just objects, with the english sentence as the key and the translation as the value. |
758 | `fr.json` could contain for example: | 757 | `fr.json` could contain for example: |