diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-01 08:26:28 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-01 08:26:28 +0100 |
commit | 71e5de3865f7f1c49feb5d94c0c658261bac38a3 (patch) | |
tree | 4ba1717769d9a0b59927a3df5c86573c8d312356 /core/js | |
parent | 91f01d2c7ed9f32e9326aeaca6b3f0c6dcfb0f64 (diff) | |
parent | 0091df2bc8eed432df9d726d5bea09ac527128d2 (diff) | |
download | nextcloud-server-71e5de3865f7f1c49feb5d94c0c658261bac38a3.tar.gz nextcloud-server-71e5de3865f7f1c49feb5d94c0c658261bac38a3.zip |
Merge pull request #22677 from owncloud/allow-to-overwrite-single-l10n-string-via-theme
Allow to overwrite a single language string via the theme folder
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/l10n.js | 18 | ||||
-rw-r--r-- | core/js/tests/specs/l10nSpec.js | 8 |
2 files changed, 20 insertions, 6 deletions
diff --git a/core/js/l10n.js b/core/js/l10n.js index fb93d7b789e..43cfc7e820f 100644 --- a/core/js/l10n.js +++ b/core/js/l10n.js @@ -66,13 +66,19 @@ OC.L10N = { * @param {Function|String} [pluralForm] optional plural function or plural string */ register: function(appName, bundle, pluralForm) { - this._bundles[appName] = bundle || {}; - - if (_.isFunction(pluralForm)) { - this._pluralFunctions[appName] = pluralForm; + var self = this; + if (_.isUndefined(this._bundles[appName])) { + this._bundles[appName] = bundle || {}; + + if (_.isFunction(pluralForm)) { + this._pluralFunctions[appName] = pluralForm; + } else { + // generate plural function based on form + this._pluralFunctions[appName] = this._generatePluralFunction(pluralForm); + } } else { - // generate plural function based on form - this._pluralFunctions[appName] = this._generatePluralFunction(pluralForm); + // Theme overwriting the default language + _.extend(self._bundles[appName], bundle); } }, diff --git a/core/js/tests/specs/l10nSpec.js b/core/js/tests/specs/l10nSpec.js index bafc7746d6c..2ceb2f4a916 100644 --- a/core/js/tests/specs/l10nSpec.js +++ b/core/js/tests/specs/l10nSpec.js @@ -52,6 +52,14 @@ describe('OC.L10N tests', function() { t(TEST_APP, 'Hello {name}', {name: '<strong>Steve</strong>'}, null, {escape: false}) ).toEqual('Hello <strong>Steve</strong>'); }); + it('keeps old texts when registering existing bundle', function() { + OC.L10N.register(TEST_APP, { + 'sunny': 'sonnig', + 'new': 'neu' + }); + expect(t(TEST_APP, 'sunny')).toEqual('sonnig'); + expect(t(TEST_APP, 'new')).toEqual('neu'); + }); }); describe('plurals', function() { function checkPlurals() { |