uilanguages.html 4.5 KB

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