Skip to content

Commit

Permalink
Merge pull request #36287 from nextcloud/feat/switch-pkg-l10n
Browse files Browse the repository at this point in the history
Deprecate and cleanup `OC.L10N` in favor of `@nextcloud/l10n`
  • Loading branch information
juliushaertl authored Feb 20, 2023
2 parents 3204f97 + bfad19c commit 21f9688
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 474 deletions.
9 changes: 6 additions & 3 deletions core/js/tests/specs/l10nSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ describe('OC.L10N tests', function() {
});
});
describe('async loading of translations', function() {
afterEach(() => {
document.documentElement.removeAttribute('data-locale')
})
it('loads bundle for given app and calls callback', function(done) {
var localeStub = sinon.stub(OC, 'getLocale').returns('zh_CN');
document.documentElement.setAttribute('data-locale', 'zh_CN')
var callbackStub = sinon.stub();
var promiseStub = sinon.stub();
var loading = OC.L10N.load(TEST_APP, callbackStub);
Expand All @@ -129,9 +132,9 @@ describe('OC.L10N tests', function() {
expect(callbackStub.calledOnce).toEqual(true);
expect(promiseStub.calledOnce).toEqual(true);
expect(t(TEST_APP, 'Hello world!')).toEqual('你好世界!');
localeStub.restore();
})
.then(done);
.then(done)
.catch(e => expect(e).toBe('No error expected!'));

expect(promiseStub.notCalled).toEqual(true);
req.respond(
Expand Down
20 changes: 8 additions & 12 deletions core/src/OC/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@ import {
unregisterMenu,
} from './menu'
import { isUserAdmin } from './admin'
import L10N, {
getLanguage,
getLocale,
} from './l10n'
import L10N from './l10n'
import {
getCanonicalLocale,
getLanguage,
getLocale,
} from '@nextcloud/l10n'

import {
Expand Down Expand Up @@ -231,17 +230,14 @@ export default {
* @deprecated 20.0.0 use `getCanonicalLocale` from https://www.npmjs.com/package/@nextcloud/l10n
*/
getCanonicalLocale,
/**
* @deprecated 26.0.0 use `getLocale` from https://www.npmjs.com/package/@nextcloud/l10n
*/
getLocale,
getLanguage,
/**
* Loads translations for the given app asynchronously.
*
* @param {string} app app name
* @param {Function} callback callback to call after loading
* @return {Promise}
* @deprecated 17.0.0 use OC.L10N.load instead
* @deprecated 26.0.0 use `getLanguage` from https://www.npmjs.com/package/@nextcloud/l10n
*/
addTranslations: L10N.load,
getLanguage,

/**
* Query string helpers
Expand Down
90 changes: 0 additions & 90 deletions core/src/OC/l10n-registry.js

This file was deleted.

Loading

0 comments on commit 21f9688

Please sign in to comment.