3 Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved.
4 For licensing, see LICENSE.md or http://ckeditor.com/license
9 <title>User Interface Globalization
— CKEditor Sample
</title>
10 <script src=
"../ckeditor.js"></script>
11 <script src=
"assets/uilanguages/languages.js"></script>
12 <link rel=
"stylesheet" href=
"sample.css">
16 <a href=
"index.html">CKEditor Samples
</a> » User Interface Languages
18 <div class=
"description">
20 This sample shows how to automatically replace
<code><textarea
></code> elements
21 with a CKEditor instance with an option to change the language of its user interface.
24 It pulls the language list from CKEditor
<code>_languages.js
</code> file that contains the list of supported languages and creates
25 a drop-down list that lets the user change the UI language.
28 By default, CKEditor automatically localizes the editor to the language of the user.
29 The UI language can be controlled with two configuration options:
30 <code><a class=
"samples" href=
"http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-language">language
</a></code> and
31 <code><a class=
"samples" href=
"http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-defaultLanguage">
32 defaultLanguage
</a></code>. The
<code>defaultLanguage
</code> setting specifies the
33 default CKEditor language to be used when a localization suitable for user's settings is not available.
36 To specify the user interface language that will be used no matter what language is
37 specified in user's browser or operating system, set the
<code>language
</code> property:
40 CKEDITOR.replace( '
<em>textarea_id
</em>', {
41 // Load the German interface.
42 <strong>language: 'de'
</strong>
45 Note that
<code><em>textarea_id
</em></code> in the code above is the
<code>id
</code> attribute of
46 the
<code><textarea
></code> element to be replaced.
49 <form action=
"sample_posteddata.php" method=
"post">
51 Available languages (
<span id=
"count"> </span> languages!):
<br>
54 document.write( '
<select disabled=
"disabled" id=
"languages" onchange=
"createEditor( this.value );">' );
56 // Get the language list from the _languages.js file.
57 for ( var i =
0 ; i < window.CKEDITOR_LANGS.length ; i++ ) {
59 '
<option value=
"' + window.CKEDITOR_LANGS[i].code + '">' +
60 window.CKEDITOR_LANGS[i].name +
64 document.write( '
</select>' );
68 <span style=
"color: #888888">
69 (You may see strange characters if your system does not support the selected language)
73 <textarea cols=
"80" id=
"editor1" name=
"editor1" rows=
"10"><p
>This is some
<strong
>sample text
</strong
>. You are using
<a
href=
"http://ckeditor.com/">CKEditor
</a
>.
</p
></textarea>
76 // Set the number of languages.
77 document.getElementById( 'count' ).innerHTML = window.CKEDITOR_LANGS.length;
81 function createEditor( languageCode ) {
85 // Replace the
<textarea id=
"editor"> with an CKEditor
86 // instance, using default configurations.
87 editor = CKEDITOR.replace( 'editor1', {
88 language: languageCode,
91 instanceReady: function() {
92 // Wait for the editor to be ready to set
93 // the language combo.
94 var languages = document.getElementById( 'languages' );
95 languages.value = this.langCode;
96 languages.disabled = false;
102 // At page startup, load the default language:
111 CKEditor - The text editor for the Internet -
<a class=
"samples" href=
"http://ckeditor.com/">http://ckeditor.com
</a>
114 Copyright
© 2003-
2014,
<a class=
"samples" href=
"http://cksource.com/">CKSource
</a> - Frederico
115 Knabben. All rights reserved.