ckeditor/samples/old/uilanguages.html
author indvd00m (gotoindvdum[at]gmail[dot]com)
Thu, 15 Dec 2016 18:10:20 +0300
changeset 0 44d330dccc59
permissions -rw-r--r--
Init sample
indvd00m@0
     1
<!DOCTYPE html>
indvd00m@0
     2
<!--
indvd00m@0
     3
Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
indvd00m@0
     4
For licensing, see LICENSE.md or http://ckeditor.com/license
indvd00m@0
     5
-->
indvd00m@0
     6
<html>
indvd00m@0
     7
<head>
indvd00m@0
     8
	<meta charset="utf-8">
indvd00m@0
     9
	<title>User Interface Globalization &mdash; CKEditor Sample</title>
indvd00m@0
    10
	<script src="../../ckeditor.js"></script>
indvd00m@0
    11
	<script src="assets/uilanguages/languages.js"></script>
indvd00m@0
    12
	<link rel="stylesheet" href="sample.css">
indvd00m@0
    13
</head>
indvd00m@0
    14
<body>
indvd00m@0
    15
	<h1 class="samples">
indvd00m@0
    16
		<a href="index.html">CKEditor Samples</a> &raquo; User Interface Languages
indvd00m@0
    17
	</h1>
indvd00m@0
    18
	<div class="warning deprecated">
indvd00m@0
    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>.
indvd00m@0
    20
	</div>
indvd00m@0
    21
	<div class="description">
indvd00m@0
    22
		<p>
indvd00m@0
    23
			This sample shows how to automatically replace <code>&lt;textarea&gt;</code> elements
indvd00m@0
    24
			with a CKEditor instance with an option to change the language of its user interface.
indvd00m@0
    25
		</p>
indvd00m@0
    26
		<p>
indvd00m@0
    27
			It pulls the language list from CKEditor <code>_languages.js</code> file that contains the list of supported languages and creates
indvd00m@0
    28
			a drop-down list that lets the user change the UI language.
indvd00m@0
    29
		</p>
indvd00m@0
    30
		<p>
indvd00m@0
    31
			By default, CKEditor automatically localizes the editor to the language of the user.
indvd00m@0
    32
			The UI language can be controlled with two configuration options:
indvd00m@0
    33
			<code><a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-language">language</a></code> and
indvd00m@0
    34
			<code><a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-defaultLanguage">
indvd00m@0
    35
			defaultLanguage</a></code>. The <code>defaultLanguage</code> setting specifies the
indvd00m@0
    36
			default CKEditor language to be used when a localization suitable for user's settings is not available.
indvd00m@0
    37
		</p>
indvd00m@0
    38
		<p>
indvd00m@0
    39
			To specify the user interface language that will be used no matter what language is
indvd00m@0
    40
			specified in user's browser or operating system, set the <code>language</code> property:
indvd00m@0
    41
		</p>
indvd00m@0
    42
<pre class="samples">
indvd00m@0
    43
CKEDITOR.replace( '<em>textarea_id</em>', {
indvd00m@0
    44
	// Load the German interface.
indvd00m@0
    45
	<strong>language: 'de'</strong>
indvd00m@0
    46
});</pre>
indvd00m@0
    47
		<p>
indvd00m@0
    48
			Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of
indvd00m@0
    49
			the <code>&lt;textarea&gt;</code> element to be replaced.
indvd00m@0
    50
		</p>
indvd00m@0
    51
	</div>
indvd00m@0
    52
	<form action="sample_posteddata.php" method="post">
indvd00m@0
    53
		<p>
indvd00m@0
    54
			Available languages (<span id="count"> </span> languages!):<br>
indvd00m@0
    55
			<script>
indvd00m@0
    56
indvd00m@0
    57
				document.write( '<select disabled="disabled" id="languages" onchange="createEditor( this.value );">' );
indvd00m@0
    58
indvd00m@0
    59
				// Get the language list from the _languages.js file.
indvd00m@0
    60
				for ( var i = 0 ; i < window.CKEDITOR_LANGS.length ; i++ ) {
indvd00m@0
    61
					document.write(
indvd00m@0
    62
						'<option value="' + window.CKEDITOR_LANGS[i].code + '">' +
indvd00m@0
    63
							window.CKEDITOR_LANGS[i].name +
indvd00m@0
    64
						'</option>' );
indvd00m@0
    65
				}
indvd00m@0
    66
indvd00m@0
    67
				document.write( '</select>' );
indvd00m@0
    68
indvd00m@0
    69
			</script>
indvd00m@0
    70
			<br>
indvd00m@0
    71
			<span style="color: #888888">
indvd00m@0
    72
				(You may see strange characters if your system does not support the selected language)
indvd00m@0
    73
			</span>
indvd00m@0
    74
		</p>
indvd00m@0
    75
		<p>
indvd00m@0
    76
			<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>
indvd00m@0
    77
			<script>
indvd00m@0
    78
indvd00m@0
    79
				// Set the number of languages.
indvd00m@0
    80
				document.getElementById( 'count' ).innerHTML = window.CKEDITOR_LANGS.length;
indvd00m@0
    81
indvd00m@0
    82
				var editor;
indvd00m@0
    83
indvd00m@0
    84
				function createEditor( languageCode ) {
indvd00m@0
    85
					if ( editor )
indvd00m@0
    86
						editor.destroy();
indvd00m@0
    87
indvd00m@0
    88
					// Replace the <textarea id="editor"> with an CKEditor
indvd00m@0
    89
					// instance, using default configurations.
indvd00m@0
    90
					editor = CKEDITOR.replace( 'editor1', {
indvd00m@0
    91
						language: languageCode,
indvd00m@0
    92
indvd00m@0
    93
						on: {
indvd00m@0
    94
							instanceReady: function() {
indvd00m@0
    95
								// Wait for the editor to be ready to set
indvd00m@0
    96
								// the language combo.
indvd00m@0
    97
								var languages = document.getElementById( 'languages' );
indvd00m@0
    98
								languages.value = this.langCode;
indvd00m@0
    99
								languages.disabled = false;
indvd00m@0
   100
							}
indvd00m@0
   101
						}
indvd00m@0
   102
					});
indvd00m@0
   103
				}
indvd00m@0
   104
indvd00m@0
   105
				// At page startup, load the default language:
indvd00m@0
   106
				createEditor( '' );
indvd00m@0
   107
indvd00m@0
   108
			</script>
indvd00m@0
   109
		</p>
indvd00m@0
   110
	</form>
indvd00m@0
   111
	<div id="footer">
indvd00m@0
   112
		<hr>
indvd00m@0
   113
		<p>
indvd00m@0
   114
			CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
indvd00m@0
   115
		</p>
indvd00m@0
   116
		<p id="copy">
indvd00m@0
   117
			Copyright &copy; 2003-2016, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
indvd00m@0
   118
			Knabben. All rights reserved.
indvd00m@0
   119
		</p>
indvd00m@0
   120
	</div>
indvd00m@0
   121
</body>
indvd00m@0
   122
</html>