danielebarchiesi@0
|
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
danielebarchiesi@0
|
2 <!--
|
danielebarchiesi@0
|
3 Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
|
danielebarchiesi@0
|
4 For licensing, see LICENSE.html or http://ckeditor.com/license
|
danielebarchiesi@0
|
5 -->
|
danielebarchiesi@0
|
6 <html xmlns="http://www.w3.org/1999/xhtml">
|
danielebarchiesi@0
|
7 <head>
|
danielebarchiesi@0
|
8 <title>User Interface Globalization — CKEditor Sample</title>
|
danielebarchiesi@0
|
9 <meta content="text/html; charset=utf-8" http-equiv="content-type" />
|
danielebarchiesi@0
|
10 <script type="text/javascript" src="../ckeditor.js"></script>
|
danielebarchiesi@0
|
11 <script type="text/javascript" src="../lang/_languages.js"></script>
|
danielebarchiesi@0
|
12 <script src="sample.js" type="text/javascript"></script>
|
danielebarchiesi@0
|
13 <link href="sample.css" rel="stylesheet" type="text/css" />
|
danielebarchiesi@0
|
14 </head>
|
danielebarchiesi@0
|
15 <body>
|
danielebarchiesi@0
|
16 <h1 class="samples">
|
danielebarchiesi@0
|
17 CKEditor Sample — User Interface Languages
|
danielebarchiesi@0
|
18 </h1>
|
danielebarchiesi@0
|
19 <div class="description">
|
danielebarchiesi@0
|
20 <p>
|
danielebarchiesi@0
|
21 This sample shows how to automatically replace <code><textarea></code> elements
|
danielebarchiesi@0
|
22 with a CKEditor instance with an option to change the language of its user interface.
|
danielebarchiesi@0
|
23 </p>
|
danielebarchiesi@0
|
24 <p>
|
danielebarchiesi@0
|
25 It pulls the language list from CKEditor <code>_languages.js</code> file that contains the list of supported languages and creates
|
danielebarchiesi@0
|
26 a drop-down list that lets the user change the UI language.
|
danielebarchiesi@0
|
27 </p>
|
danielebarchiesi@0
|
28 <p>
|
danielebarchiesi@0
|
29 By default, CKEditor automatically localizes the editor to the language of the user.
|
danielebarchiesi@0
|
30 The UI language can be controlled with two configuration options:
|
danielebarchiesi@0
|
31 <a class="samples" href="http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.language">
|
danielebarchiesi@0
|
32 <code>language</code></a> and <a class="samples" href="http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.defaultLanguage">
|
danielebarchiesi@0
|
33 <code>defaultLanguage</code></a>. The <code>defaultLanguage</code> setting specifies the
|
danielebarchiesi@0
|
34 default CKEditor language to be used when a localization suitable for user's settings is not available.
|
danielebarchiesi@0
|
35 </p>
|
danielebarchiesi@0
|
36 <p>
|
danielebarchiesi@0
|
37 To specify the user interface language that will be used no matter what language is
|
danielebarchiesi@0
|
38 specified in user's browser or operating system, set the <code>language</code> property:
|
danielebarchiesi@0
|
39 </p>
|
danielebarchiesi@0
|
40 <pre class="samples">CKEDITOR.replace( '<em>textarea_id</em>',
|
danielebarchiesi@0
|
41 {
|
danielebarchiesi@0
|
42 // Load the German interface.
|
danielebarchiesi@0
|
43 <strong>language: 'de'</strong>
|
danielebarchiesi@0
|
44 });</pre>
|
danielebarchiesi@0
|
45 <p>
|
danielebarchiesi@0
|
46 Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of
|
danielebarchiesi@0
|
47 the <code><textarea></code> element to be replaced.
|
danielebarchiesi@0
|
48 </p>
|
danielebarchiesi@0
|
49 </div>
|
danielebarchiesi@0
|
50 <!-- This <div> holds alert messages to be display in the sample page. -->
|
danielebarchiesi@0
|
51 <div id="alerts">
|
danielebarchiesi@0
|
52 <noscript>
|
danielebarchiesi@0
|
53 <p>
|
danielebarchiesi@0
|
54 <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
|
danielebarchiesi@0
|
55 support, like yours, you should still see the contents (HTML data) and you should
|
danielebarchiesi@0
|
56 be able to edit it normally, without a rich editor interface.
|
danielebarchiesi@0
|
57 </p>
|
danielebarchiesi@0
|
58 </noscript>
|
danielebarchiesi@0
|
59 </div>
|
danielebarchiesi@0
|
60 <form action="sample_posteddata.php" method="post">
|
danielebarchiesi@0
|
61 <p>
|
danielebarchiesi@0
|
62 Available languages (<span id="count"> </span> languages!):<br />
|
danielebarchiesi@0
|
63 <script type="text/javascript">
|
danielebarchiesi@0
|
64 //<![CDATA[
|
danielebarchiesi@0
|
65 document.write( '<select disabled="disabled" id="languages" onchange="createEditor( this.value );">' );
|
danielebarchiesi@0
|
66 // Get the language list from the _languages.js file.
|
danielebarchiesi@0
|
67 for ( var i = 0 ; i < window.CKEDITOR_LANGS.length ; i++ )
|
danielebarchiesi@0
|
68 {
|
danielebarchiesi@0
|
69 document.write(
|
danielebarchiesi@0
|
70 '<option value="' + window.CKEDITOR_LANGS[i].code + '">' +
|
danielebarchiesi@0
|
71 window.CKEDITOR_LANGS[i].name +
|
danielebarchiesi@0
|
72 '</option>' );
|
danielebarchiesi@0
|
73 }
|
danielebarchiesi@0
|
74 document.write( '</select>' );
|
danielebarchiesi@0
|
75 //]]>
|
danielebarchiesi@0
|
76 </script>
|
danielebarchiesi@0
|
77 <br />
|
danielebarchiesi@0
|
78 <span style="color: #888888">(You may see strange characters if your system does not
|
danielebarchiesi@0
|
79 support the selected language)</span>
|
danielebarchiesi@0
|
80 </p>
|
danielebarchiesi@0
|
81 <p>
|
danielebarchiesi@0
|
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>
|
danielebarchiesi@0
|
83 <script type="text/javascript">
|
danielebarchiesi@0
|
84 //<![CDATA[
|
danielebarchiesi@0
|
85
|
danielebarchiesi@0
|
86 // Set the number of languages.
|
danielebarchiesi@0
|
87 document.getElementById( 'count' ).innerHTML = window.CKEDITOR_LANGS.length;
|
danielebarchiesi@0
|
88
|
danielebarchiesi@0
|
89 var editor;
|
danielebarchiesi@0
|
90
|
danielebarchiesi@0
|
91 function createEditor( languageCode )
|
danielebarchiesi@0
|
92 {
|
danielebarchiesi@0
|
93 if ( editor )
|
danielebarchiesi@0
|
94 editor.destroy();
|
danielebarchiesi@0
|
95
|
danielebarchiesi@0
|
96 // Replace the <textarea id="editor"> with an CKEditor
|
danielebarchiesi@0
|
97 // instance, using default configurations.
|
danielebarchiesi@0
|
98 editor = CKEDITOR.replace( 'editor1',
|
danielebarchiesi@0
|
99 {
|
danielebarchiesi@0
|
100 language : languageCode,
|
danielebarchiesi@0
|
101
|
danielebarchiesi@0
|
102 on :
|
danielebarchiesi@0
|
103 {
|
danielebarchiesi@0
|
104 instanceReady : function()
|
danielebarchiesi@0
|
105 {
|
danielebarchiesi@0
|
106 // Wait for the editor to be ready to set
|
danielebarchiesi@0
|
107 // the language combo.
|
danielebarchiesi@0
|
108 var languages = document.getElementById( 'languages' );
|
danielebarchiesi@0
|
109 languages.value = this.langCode;
|
danielebarchiesi@0
|
110 languages.disabled = false;
|
danielebarchiesi@0
|
111 }
|
danielebarchiesi@0
|
112 }
|
danielebarchiesi@0
|
113 } );
|
danielebarchiesi@0
|
114 }
|
danielebarchiesi@0
|
115
|
danielebarchiesi@0
|
116 // At page startup, load the default language:
|
danielebarchiesi@0
|
117 createEditor( '' );
|
danielebarchiesi@0
|
118
|
danielebarchiesi@0
|
119 //]]>
|
danielebarchiesi@0
|
120 </script>
|
danielebarchiesi@0
|
121 </p>
|
danielebarchiesi@0
|
122 </form>
|
danielebarchiesi@0
|
123 <div id="footer">
|
danielebarchiesi@0
|
124 <hr />
|
danielebarchiesi@0
|
125 <p>
|
danielebarchiesi@0
|
126 CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
|
danielebarchiesi@0
|
127 </p>
|
danielebarchiesi@0
|
128 <p id="copy">
|
danielebarchiesi@0
|
129 Copyright © 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
|
danielebarchiesi@0
|
130 Knabben. All rights reserved.
|
danielebarchiesi@0
|
131 </p>
|
danielebarchiesi@0
|
132 </div>
|
danielebarchiesi@0
|
133 </body>
|
danielebarchiesi@0
|
134 </html>
|