Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Promote unregister function to public API #579

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/loadTranslations.test.ts
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -73,7 +73,7 @@ describe('loadTranslations', () => {
} catch (e) {
expect(e).toBe('Unexpected error')
} finally {
_unregister('myapp')
unregister('myapp')
}
})

Expand Down
4 changes: 2 additions & 2 deletions tests/translation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
register,
translate,
translatePlural,
_unregister,
unregister,
} from '../lib/translation'

declare const window: NextcloudWindowWithRegistry
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('register', () => {
register('app', {
Application: 'Anwendung',
})
_unregister('app')
unregister('app')
expect(translate('app', 'Application')).toBe('Application')
})
})
Expand Down