Skip to content

Commit

Permalink
fix(registration): Fix registration in standalone usage
Browse files Browse the repository at this point in the history
Registration of a translation bundle in standalone application didn't work 
without initializing global `_oc_l10n_registry_*` objects.

Add global registry initialization in `register` function.

Signed-off-by: Grigorii Shartsev <grigorii.shartsev@nextcloud.com>
  • Loading branch information
ShGKme committed Jan 12, 2023
1 parent be7ed24 commit 090e38d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export function registerAppTranslations(
translations: Translations,
pluralFunction: PluralFunction
) {
if (window._oc_l10n_registry_translations === undefined) {
window._oc_l10n_registry_translations = {}
}
if (window._oc_l10n_registry_plural_functions === undefined) {
window._oc_l10n_registry_plural_functions = {}
}
if (!hasAppTranslations(appId)) {
setAppTranslations(appId, translations, pluralFunction)
} else {
Expand Down Expand Up @@ -64,7 +70,7 @@ export function getAppTranslations(appId: string): AppTranslations {
typeof window._oc_l10n_registry_translations === 'undefined'
|| typeof window._oc_l10n_registry_plural_functions === 'undefined'
) {
console.warn('No OC L10N registry found')
console.warn(`No translation for ${appId} found`)
return {
translations: {},
pluralFunction: (number: number) => number,
Expand Down

0 comments on commit 090e38d

Please sign in to comment.