This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from ckeditor/t/ckeditor5/1151
Feature: Allowed specifying editor content language in `Locale`. Implemented the (UI and content) language direction discovery in `Locale`. Implemented `Locale#uiLanguage`, `Locale#uiLanguageDirection`, `Locale#contentLanguage`, and `Locale#contentLanguageDirection` properties. See ckeditor/ckeditor5#1151. BREAKING CHANGE: The`Locale()` constructor arguments syntax has changed. Please refer to the API documentation to learn more. BREAKING CHANGE: The `Locale#language` property has been deprecated by `Locale#uiLanguage`. Please refer to the API documentation to learn more.
- Loading branch information
Showing
7 changed files
with
305 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<h2>language = 'en' (LTR)</h2> | ||
|
||
<div id="editor-language"> | ||
<p>This is an <a href="https://ckeditor.com">editor</a> instance.</p> | ||
<figure class="image image-style-side"><img src="./sample.jpg"><figcaption>Caption</figcaption></figure> | ||
</div> | ||
|
||
<h2>language = 'ar' (RTL)</h2> | ||
|
||
<div id="editor-language-rtl"> | ||
<p>مرحبا <a href="https://ckeditor.com">editor</a></p> | ||
<figure class="image image-style-side"><img src="./sample.jpg"><figcaption>Caption</figcaption></figure> | ||
</div> | ||
|
||
<h2>language = 'en' (LTR), <br />contentLanguage = 'ar' (RTL)</h2> | ||
|
||
<div id="editor-language-rtl-content"> | ||
<p>مرحبا <a href="https://ckeditor.com">editor</a></p> | ||
<figure class="image image-style-side"><img src="./sample.jpg"><figcaption>Caption</figcaption></figure> | ||
</div> | ||
|
||
<h2>language = 'ar' (RTL), <br />contentLanguage = 'en' (LTR)</h2> | ||
|
||
<div id="editor-language-rtl-ui"> | ||
<p>This is an <a href="https://ckeditor.com">editor</a> instance.</p> | ||
<figure class="image image-style-side"><img src="./sample.jpg"><figcaption>Caption</figcaption></figure> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/* global window, console, document */ | ||
|
||
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'; | ||
import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset'; | ||
|
||
const config = { | ||
plugins: [ ArticlePluginSet ], | ||
image: { | ||
toolbar: [ 'imageStyle:full', 'imageStyle:side', '|', 'imageTextAlternative' ] | ||
}, | ||
table: { | ||
contentToolbar: [ | ||
'tableColumn', | ||
'tableRow', | ||
'mergeTableCells' | ||
] | ||
}, | ||
toolbar: [ | ||
'heading', | ||
'|', | ||
'bold', 'italic', 'link', | ||
'bulletedList', 'numberedList', | ||
'blockQuote', 'insertTable', 'mediaEmbed', | ||
'undo', 'redo' | ||
] | ||
}; | ||
|
||
ClassicEditor | ||
.create( document.querySelector( '#editor-language' ), Object.assign( {}, config, { | ||
language: 'en' | ||
} ) ) | ||
.then( newEditor => { | ||
window.editorLanguage = newEditor; | ||
|
||
console.log( 'Editor created, locale:', newEditor.locale ); | ||
} ) | ||
.catch( err => { | ||
console.error( err.stack ); | ||
} ); | ||
|
||
ClassicEditor | ||
.create( document.querySelector( '#editor-language-rtl' ), Object.assign( {}, config, { | ||
language: 'ar' | ||
} ) ) | ||
.then( newEditor => { | ||
window.editorLanguageRTL = newEditor; | ||
|
||
console.log( 'Editor created, locale:', newEditor.locale ); | ||
} ) | ||
.catch( err => { | ||
console.error( err.stack ); | ||
} ); | ||
|
||
ClassicEditor | ||
.create( document.querySelector( '#editor-language-rtl-content' ), Object.assign( {}, config, { | ||
language: { | ||
content: 'ar' | ||
} | ||
} ) ) | ||
.then( newEditor => { | ||
window.editorLanguageRTLContent = newEditor; | ||
|
||
console.log( 'Editor created, locale:', newEditor.locale ); | ||
} ) | ||
.catch( err => { | ||
console.error( err.stack ); | ||
} ); | ||
|
||
ClassicEditor | ||
.create( document.querySelector( '#editor-language-rtl-ui' ), Object.assign( {}, config, { | ||
language: { | ||
ui: 'ar', | ||
content: 'en' | ||
} | ||
} ) ) | ||
.then( newEditor => { | ||
window.editorLanguageRTLUI = newEditor; | ||
|
||
console.log( 'Editor created, locale:', newEditor.locale ); | ||
} ) | ||
.catch( err => { | ||
console.error( err.stack ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
## Editor locales | ||
|
||
**Note**: For the best testing, run manual tests adding Arabic to [additional languages configuration](https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/testing-environment.html#running-manual-tests). | ||
|
||
--- | ||
|
||
Play with different editor configurations to make sure localization and the right–to–left language support work fine. | ||
|
||
### language = 'en' (LTR) | ||
|
||
1. Make sure the UI of the editor is English. | ||
2. Make sure the language of the content is English (`lang` attribute of th editable) and aligned to the **left** side. | ||
3. Delete **all** the content. | ||
4. Write something in Arabic. | ||
5. The text you've just written should be aligned **right**. | ||
|
||
### language = 'ar' (RTL) | ||
|
||
1. Make sure the UI of the editor is Arabic. | ||
2. Make sure the language of the content is Arabic (`lang` attribute of th editable) and aligned to the **right** side. | ||
3. Delete **all** the content. | ||
4. Write something in English. | ||
5. The text you've just written should be aligned **left**. | ||
|
||
### language = 'en' (LTR), contentLanguage = 'ar' (RTL) | ||
|
||
1. Make sure the UI of the editor is English. | ||
2. Make sure the language of the content is Arabic (`lang` attribute of th editable) and aligned to the **right** side. | ||
3. Delete **all** the content. | ||
4. Write something in English. | ||
5. The text you've just written should be aligned **right**. | ||
|
||
### language = 'ar' (RTL), contentLanguage = 'en' (LTR) | ||
|
||
1. Make sure the UI of the editor is Arabic. | ||
2. Make sure the language of the content is English (`lang` attribute of th editable) and aligned to the **left** side. | ||
3. Delete **all** the content. | ||
4. Write something in Arabic. | ||
5. The text you've just written should be aligned **left**. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.