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

Deprecate and cleanup OC.L10N in favor of @nextcloud/l10n #36287

Merged
merged 4 commits into from
Feb 20, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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