瀏覽代碼

Added language configuration to the context when it is created by the editor.

Oskar Wróbel 6 年之前
父節點
當前提交
e73857a3b1
共有 2 個文件被更改,包括 10 次插入1 次删除
  1. 1 1
      packages/ckeditor5-core/src/editor/editor.js
  2. 9 0
      packages/ckeditor5-core/tests/editor/editor.js

+ 1 - 1
packages/ckeditor5-core/src/editor/editor.js

@@ -55,7 +55,7 @@ export default class Editor {
 		 * @readonly
 		 * @type {module:core/context~Context}
 		 */
-		this.context = config.context || new Context();
+		this.context = config.context || new Context( { language: config.language } );
 		this.context.addEditor( this );
 
 		/**

+ 9 - 0
packages/ckeditor5-core/tests/editor/editor.js

@@ -278,6 +278,15 @@ describe( 'Editor', () => {
 			expect( editor.locale ).to.equal( editor.context.locale ).to.instanceof( Locale );
 			expect( editor.t ).to.equal( editor.context.t );
 		} );
+
+		it( 'should use locale instance with a proper configuration', () => {
+			const editor = new TestEditor( {
+				language: 'pl'
+			} );
+
+			expect( editor.locale ).to.have.property( 'uiLanguage', 'pl' );
+			expect( editor.locale ).to.have.property( 'contentLanguage', 'pl' );
+		} );
 	} );
 
 	describe( 'state', () => {