Skip to content

Commit

Permalink
Merge pull request #579 from nextcloud/enh/promote-unregister
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv committed Feb 3, 2023
2 parents bbde159 + 675e27d commit f885297
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
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

0 comments on commit f885297

Please sign in to comment.