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