diff --git a/src/js/ckeditor-loader.js b/src/js/ckeditor-loader.js index 57630b6c..2df4ed3b 100644 --- a/src/js/ckeditor-loader.js +++ b/src/js/ckeditor-loader.js @@ -9,9 +9,11 @@ // and thus it would make it impossible to test this part of the code. $(window).load(function () { $('[data-onload-ckeditor]').each(function () { + var language = $('html').attr('lang'); var confObj = {}; var $this = $(this); var confValue = $this.data('onload-ckeditor'); + if (confValue) { if (typeof confValue === 'object') { confObj = confValue; @@ -20,6 +22,10 @@ } } + if (language) { + confObj.language = language; + } + $this.ckeditor(confObj); }); }); diff --git a/src/js/tests/unit/ckeditor-loader.js b/src/js/tests/unit/ckeditor-loader.js index f800b9ce..8c2f7049 100644 --- a/src/js/tests/unit/ckeditor-loader.js +++ b/src/js/tests/unit/ckeditor-loader.js @@ -59,4 +59,19 @@ $(function () { ); }); + QUnit.test('should init ckeditor on page load with correct language settings', function () { + var $textarea = $(''); + $('#qunit-fixture').append($textarea); + + sinon.spy(jQuery.fn, 'ckeditor'); + $('html').attr('lang', 'cs'); + $(window).trigger('load'); + + QUnit.ok(jQuery.fn.ckeditor.calledOnce, 'Should init the ckeditor'); + QUnit.ok( + jQuery.fn.ckeditor.calledWithExactly({ language: 'cs' }), + 'Should init the ckeditor with proper config object' + ); + }); + }); diff --git a/src/less/components/javascript/ckeditor-loader.less b/src/less/components/javascript/ckeditor-loader.less index 92a1cfdc..471b2115 100644 --- a/src/less/components/javascript/ckeditor-loader.less +++ b/src/less/components/javascript/ckeditor-loader.less @@ -14,8 +14,8 @@ options. ### Usage -This loader only calls the jQuery plugin defined in CKEditor jQuery adapter with appropriate arguments. Id does nothing -else. +This loader only calls the jQuery plugin defined in CKEditor jQuery adapter with appropriate arguments. +If the `lang` attribute is set on the `` element the CKEditor is localized accordingly. #### Data-API