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