From 675e27dd9dc3370e02136fb8340b7f8926b3f9db Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 2 Feb 2023 23:17:20 +0100 Subject: [PATCH] feat: Promote `unregister` function to public API Signed-off-by: Ferdinand Thiessen --- lib/translation.ts | 9 +++++++-- tests/loadTranslations.test.ts | 4 ++-- tests/translation.test.ts | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/translation.ts b/lib/translation.ts index a4fa3bf9..101ef82c 100644 --- a/lib/translation.ts +++ b/lib/translation.ts @@ -195,9 +195,14 @@ export function register(appName: string, bundle: Translations) { } /** - * @private + * Unregister all translations of an app + * + * @param appName name of the app + * @since 2.1.0 */ -export const _unregister = unregisterAppTranslations +export function unregister(appName: string) { + return unregisterAppTranslations(appName) +} /** * Get array index of translations for a plural form diff --git a/tests/loadTranslations.test.ts b/tests/loadTranslations.test.ts index b9a04335..ebd61210 100644 --- a/tests/loadTranslations.test.ts +++ b/tests/loadTranslations.test.ts @@ -1,6 +1,6 @@ import { MockXhrServer, newServer } from 'mock-xmlhttprequest' -import { loadTranslations, register, translate, _unregister } from '../lib/translation' +import { loadTranslations, register, translate, unregister } from '../lib/translation' const setLocale = (locale) => document.documentElement.setAttribute('data-locale', locale) @@ -73,7 +73,7 @@ describe('loadTranslations', () => { } catch (e) { expect(e).toBe('Unexpected error') } finally { - _unregister('myapp') + unregister('myapp') } }) diff --git a/tests/translation.test.ts b/tests/translation.test.ts index a8af1e9f..5c877f51 100644 --- a/tests/translation.test.ts +++ b/tests/translation.test.ts @@ -7,7 +7,7 @@ import { register, translate, translatePlural, - _unregister, + unregister, } from '../lib/translation' declare const window: NextcloudWindowWithRegistry @@ -237,7 +237,7 @@ describe('register', () => { register('app', { Application: 'Anwendung', }) - _unregister('app') + unregister('app') expect(translate('app', 'Application')).toBe('Application') }) })