-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Align docs to the new Translation Service #694
Changes from 3 commits
541f111
e4a6e10
0f688c1
2e7b446
876826d
ad88199
7816c4d
b776391
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ See the demo of the editor in German: | |
|
||
## Building the editor using a specific language | ||
|
||
Currently, it is only possible to change the UI language at the build stage. A single build of the editor supports only the language which was defined in the [CKEditor 5 webpack plugin](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-webpack-plugin)'s configuration. | ||
Currently, it is possible to change the UI language at the build stage and after the build. A single build of the editor supports the language which was defined in the [CKEditor 5 webpack plugin](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-webpack-plugin)'s configuration. See the whole translation process to see how you can change the language later. | ||
|
||
If you use one of the {@link builds/index predefined editor builds}, refer to {@link builds/guides/development/custom-builds Creating custom builds} to learn how to change the language of your build. | ||
|
||
|
@@ -37,19 +37,49 @@ If you build CKEditor from scratch or integrate it directly into your applicatio | |
// Define webpack plugins ... | ||
plugins: [ | ||
new CKEditorWebpackPlugin( { | ||
// Note: The plugin is currently able to build just one language at a time. | ||
languages: [ 'pl' ] | ||
// Main language that will be built in to the main bundle. | ||
language: 'en', | ||
|
||
// Additional languages that will be emitted to the `outputDirectory`. | ||
// This option can be set to array of language codes or `'all'` to build all found languages. | ||
// The bundle is optimized for one language when this option is omitted. | ||
additionalLanguages: 'all', | ||
|
||
// Optional directory for emitted translations, `'lang'` by default. | ||
// Relative to the webpack's output. | ||
outputDirectory: 'lang', | ||
|
||
// Optional flag indicates breaking the build process when the error is found. | ||
throwErrorOnMissingTranslation: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I just wanted to list available options with their default values. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can mention the default value of each option in a comment. |
||
} ), | ||
|
||
// Other webpack plugins... | ||
] | ||
// ... | ||
``` | ||
|
||
3. Run webpack. The CKEditor plugin for webpack will replace the {@link module:utils/locale~Locale#t `t()`} function calls used in the source code with localized language strings. | ||
3. Run webpack. If the `additionalLanguages` option is not set, the CKEditor plugin for webpack will replace the {@link module:utils/locale~Locale#t `t()`} function call parameters used in the source code with localized language strings. Otherwise the CKEditor plugin for webpack will replace the {@link module:utils/locale~Locale#t `t()`} function call parameters with short ids and emit the translation files that should land in the `'lang'` directory (or different, if the `outputDirectory` option is specified). | ||
|
||
4. If you want to change the language after the build ends, you will need to edit the `index.html` file, add the translation file and set the UI language to the target one. | ||
|
||
```html | ||
<script src="../build/ckeditor.js"></script> | ||
<script src="../build/lang/pl.js"></script> | ||
<script> | ||
ClassicEditor.create( document.querySelector( '#editor' ), { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ClassicEditor
.create( {
} )
.then()
.catch(); |
||
language: 'pl' | ||
} ) | ||
.then( editor => { | ||
window.editor = editor; | ||
} ) | ||
.catch( err => { | ||
console.error( err.stack ); | ||
} ); | ||
</script> | ||
``` | ||
|
||
<info-box> | ||
We are aware that the current localization method is not sufficient for all needs. It neither supports different bundlers (e.g. Rollup or Browserify) nor building multiple languages (to make it possible to pick one at runtime). We will be extending the localization possiblities in the near future. | ||
We are aware that the current localization method is not sufficient for all needs. It doesn't support different bundlers (e.g. Rollup or Browserify). We will be extending the localization possibilities in the future. | ||
|
||
You can read more about the used techniques and future plans in the ["Implement translation services" issue](https://github.com/ckeditor/ckeditor5/issues/387). | ||
You can read more about the used techniques in the ["Implement translation services" issue](https://github.com/ckeditor/ckeditor5/issues/387) and ["Implement translation services v2" issue](https://github.com/ckeditor/ckeditor5/issues/624). | ||
</info-box> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This guide needs to be pretty much rewritten rather than patched. Since the whole picture changed dramatically we need to put focus on different things.
The current intro can stay.
But then we should explain how to initialize the editor from CDN/zip/npm with a different language. This is what most people will want to do. Please also review other guides like
installation.md
and other places where we list files available in a build because that list needs to be updated (and perhaps link to the ui-language.md guide):Then we can provide a few more details on what other options people have:
At the end we can mention that compiling editor translations is only available for Webpack and we will be extending support for other bundlers in the future. If we want to mention those tickets about translations services we should explain why we mention them. Something like – if you'd like to tinker with one of the bundlers you can read about CKEditor 5's translation service here and here.