ui_languages.html 4.9 KB

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