1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
4 For licensing, see LICENSE.html or http://ckeditor.com/license
6 <html xmlns=
"http://www.w3.org/1999/xhtml">
8 <title>User Interface Globalization
— CKEditor Sample
</title>
9 <meta content=
"text/html; charset=utf-8" http-equiv=
"content-type" />
10 <script type=
"text/javascript" src=
"../ckeditor.js"></script>
11 <script type=
"text/javascript" src=
"../lang/_languages.js"></script>
12 <script src=
"sample.js" type=
"text/javascript"></script>
13 <link href=
"sample.css" rel=
"stylesheet" type=
"text/css" />
17 CKEditor Sample
— User Interface Languages
19 <div class=
"description">
21 This sample shows how to automatically replace
<code><textarea
></code> elements
22 with a CKEditor instance with an option to change the language of its user interface.
25 It pulls the language list from CKEditor
<code>_languages.js
</code> file that contains the list of supported languages and creates
26 a drop-down list that lets the user change the UI language.
29 By default, CKEditor automatically localizes the editor to the language of the user.
30 The UI language can be controlled with two configuration options:
31 <a class=
"samples" href=
"http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.language">
32 <code>language
</code></a> and
<a class=
"samples" href=
"http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.defaultLanguage">
33 <code>defaultLanguage
</code></a>. The
<code>defaultLanguage
</code> setting specifies the
34 default CKEditor language to be used when a localization suitable for user's settings is not available.
37 To specify the user interface language that will be used no matter what language is
38 specified in user's browser or operating system, set the
<code>language
</code> property:
40 <pre class=
"samples">CKEDITOR.replace( '
<em>textarea_id
</em>',
42 // Load the German interface.
43 <strong>language: 'de'
</strong>
46 Note that
<code><em>textarea_id
</em></code> in the code above is the
<code>id
</code> attribute of
47 the
<code><textarea
></code> element to be replaced.
50 <!-- This <div> holds alert messages to be display in the sample page. -->
54 <strong>CKEditor requires JavaScript to run
</strong>. In a browser with no JavaScript
55 support, like yours, you should still see the contents (HTML data) and you should
56 be able to edit it normally, without a rich editor interface.
60 <form action=
"sample_posteddata.php" method=
"post">
62 Available languages (
<span id=
"count"> </span> languages!):
<br />
63 <script type=
"text/javascript">
65 document.write( '
<select disabled=
"disabled" id=
"languages" onchange=
"createEditor( this.value );">' );
66 // Get the language list from the _languages.js file.
67 for ( var i =
0 ; i < window.CKEDITOR_LANGS.length ; i++ )
70 '
<option value=
"' + window.CKEDITOR_LANGS[i].code + '">' +
71 window.CKEDITOR_LANGS[i].name +
74 document.write( '
</select>' );
78 <span style=
"color: #888888">(You may see strange characters if your system does not
79 support the selected language)
</span>
82 <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>
83 <script type=
"text/javascript">
86 // Set the number of languages.
87 document.getElementById( 'count' ).innerHTML = window.CKEDITOR_LANGS.length;
91 function createEditor( languageCode )
96 // Replace the
<textarea id=
"editor"> with an CKEditor
97 // instance, using default configurations.
98 editor = CKEDITOR.replace( 'editor1',
100 language : languageCode,
104 instanceReady : function()
106 // Wait for the editor to be ready to set
107 // the language combo.
108 var languages = document.getElementById( 'languages' );
109 languages.value = this.langCode;
110 languages.disabled = false;
116 // At page startup, load the default language:
126 CKEditor - The text editor for the Internet -
<a class=
"samples" href=
"http://ckeditor.com/">http://ckeditor.com
</a>
129 Copyright
© 2003-
2011,
<a class=
"samples" href=
"http://cksource.com/">CKSource
</a> - Frederico
130 Knabben. All rights reserved.