Ver Fonte

Aligned docs to the new Translation Service.

Maciej Bukowski há 8 anos atrás
pai
commit
541f111cd0

+ 4 - 4
docs/builds/guides/development/custom-builds.md

@@ -106,12 +106,12 @@ module.exports = {
 		'../relative/path/to/some/othercustomplugin'
 	],
 
-	// UI language. Language codes follow the https://en.wikipedia.org/wiki/ISO_639-1 format.
-	language: 'en',
-
 	// Editor configuration.
 	config: {
-		toolbar: [ 'headings', 'bold', 'italic', 'custombutton' ]
+		toolbar: [ 'headings', 'bold', 'italic', 'custombutton' ],
+
+		// UI language. Language codes follow the https://en.wikipedia.org/wiki/ISO_639-1 format.
+		lang: 'en'
 	}
 };
 ```

+ 2 - 6
docs/builds/guides/integration/advanced-setup.md

@@ -11,7 +11,7 @@ In this guide, we would like to show you ways to closer integrate CKEditor with
 
 ## Bundler
 
-CKEditor 5 is currently built using [webpack](https://webpack.js.org) (>=2.x.x). All builds, examples and demos are generated using this bundler. It should also be possible to build CKEditor using other bundlers (if they are configured properly), such as [Rollup](https://github.com/rollup/rollup) or [Browserify](http://browserify.org/) but these setups are not officially supported yet. Also, the [`@ckeditor/ckeditor5-dev-webpack-plugin`](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-webpack-plugin) that allows to localize the editor is only available for webpack. More work on this subject will be done after v1.0.0.
+CKEditor 5 is currently built using [webpack](https://webpack.js.org) (>=3.x.x). All builds, examples and demos are generated using this bundler. It should also be possible to build CKEditor using other bundlers (if they are configured properly), such as [Rollup](https://github.com/rollup/rollup) or [Browserify](http://browserify.org/) but these setups are not officially supported yet. Also, the [`@ckeditor/ckeditor5-dev-webpack-plugin`](https://www.npmjs.com/package/@ckeditor/ckeditor5-dev-webpack-plugin) that allows to localize the editor is only available for webpack. More work on this subject will be done after v1.0.0.
 
 Therefore, **a prerequisite to this guide is that you are using webpack as your build tool**.
 
@@ -19,10 +19,6 @@ Therefore, **a prerequisite to this guide is that you are using webpack as your
 
 This is the simplest scenario. It assumes that you want to use {@link builds/guides/overview#Available-builds one of the existing builds} "as-is" (you can, of course, still {@link builds/guides/integration/configuration configure the editor}). It also gives the fastest build times.
 
-<info-box>
-	At the current stage, builds are only available in English. {@link features/ui-language Setting editor UI language} requires rebuilding the editor which means that this scenario is quite limited.
-</info-box>
-
 First, install the build of your choice {@link builds/guides/integration/installation#npm from npm}:
 
 ```bash
@@ -119,7 +115,7 @@ module.exports = {
 
 		new CKEditorWebpackPlugin( {
 			// See https://ckeditor5.github.io/docs/nightly/ckeditor5/latest/features/ui-language.html
-			languages: [ 'pl' ]
+			language: 'pl'
 		} )
 	],
 

+ 36 - 6
docs/features/ui-language.md

@@ -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,8 +37,20 @@ 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
 			} ),
 
 			// Other webpack plugins...
@@ -46,10 +58,28 @@ If you build CKEditor from scratch or integrate it directly into your applicatio
 	// ...
 	```
 
-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' ), {
+			lang: '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>

+ 1 - 1
scripts/docs/snippet-adapter/snippetadapter.js

@@ -88,7 +88,7 @@ function getWebpackConfig( config ) {
 	const plugins = [
 		new ExtractTextPlugin( 'snippet.css' ),
 		new CKEditorWebpackPlugin( {
-			languages: [ config.language || 'en' ]
+			language: config.language || 'en'
 		} ),
 		new webpack.BannerPlugin( {
 			banner: bundler.getLicenseBanner(),