You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
4.2 KiB

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