3 Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
\r
4 For licensing, see LICENSE.md or http://ckeditor.com/license
\r
8 <meta charset="utf-8">
\r
9 <title>User Interface Globalization — CKEditor Sample</title>
\r
10 <script src="../../ckeditor.js"></script>
\r
11 <script src="assets/uilanguages/languages.js"></script>
\r
12 <link rel="stylesheet" href="sample.css">
\r
15 <h1 class="samples">
\r
16 <a href="index.html">CKEditor Samples</a> » User Interface Languages
\r
18 <div class="warning deprecated">
\r
19 This sample is not maintained anymore. Check out its <a href="http://sdk.ckeditor.com/samples/uilanguages.html">brand new version in CKEditor SDK</a>.
\r
21 <div class="description">
\r
23 This sample shows how to automatically replace <code><textarea></code> elements
\r
24 with a CKEditor instance with an option to change the language of its user interface.
\r
27 It pulls the language list from CKEditor <code>_languages.js</code> file that contains the list of supported languages and creates
\r
28 a drop-down list that lets the user change the UI language.
\r
31 By default, CKEditor automatically localizes the editor to the language of the user.
\r
32 The UI language can be controlled with two configuration options:
\r
33 <code><a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-language">language</a></code> and
\r
34 <code><a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-defaultLanguage">
\r
35 defaultLanguage</a></code>. The <code>defaultLanguage</code> setting specifies the
\r
36 default CKEditor language to be used when a localization suitable for user's settings is not available.
\r
39 To specify the user interface language that will be used no matter what language is
\r
40 specified in user's browser or operating system, set the <code>language</code> property:
\r
42 <pre class="samples">
\r
43 CKEDITOR.replace( '<em>textarea_id</em>', {
\r
44 // Load the German interface.
\r
45 <strong>language: 'de'</strong>
\r
48 Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of
\r
49 the <code><textarea></code> element to be replaced.
\r
52 <form action="sample_posteddata.php" method="post">
\r
54 Available languages (<span id="count"> </span> languages!):<br>
\r
57 document.write( '<select disabled="disabled" id="languages" onchange="createEditor( this.value );">' );
\r
59 // Get the language list from the _languages.js file.
\r
60 for ( var i = 0 ; i < window.CKEDITOR_LANGS.length ; i++ ) {
\r
62 '<option value="' + window.CKEDITOR_LANGS[i].code + '">' +
\r
63 window.CKEDITOR_LANGS[i].name +
\r
67 document.write( '</select>' );
\r
71 <span style="color: #888888">
\r
72 (You may see strange characters if your system does not support the selected language)
\r
76 <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>
\r
79 // Set the number of languages.
\r
80 document.getElementById( 'count' ).innerHTML = window.CKEDITOR_LANGS.length;
\r
84 function createEditor( languageCode ) {
\r
88 // Replace the <textarea id="editor"> with an CKEditor
\r
89 // instance, using default configurations.
\r
90 editor = CKEDITOR.replace( 'editor1', {
\r
91 language: languageCode,
\r
94 instanceReady: function() {
\r
95 // Wait for the editor to be ready to set
\r
96 // the language combo.
\r
97 var languages = document.getElementById( 'languages' );
\r
98 languages.value = this.langCode;
\r
99 languages.disabled = false;
\r
105 // At page startup, load the default language:
\r
106 createEditor( '' );
\r
114 CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
\r
117 Copyright © 2003-2017, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
\r
118 Knabben. All rights reserved.
\r