Browse Source

Docs: Improved `Locale` class and translation service API docs.

Maciej Bukowski 5 years ago
parent
commit
b9d6b3f3b3

+ 6 - 3
packages/ckeditor5-utils/src/locale.js

@@ -79,7 +79,7 @@ export default class Locale {
 		 * Translates the given message to the {@link #uiLanguage}. This method is also available in
 		 * {@link module:core/editor/editor~Editor#t} and {@link module:ui/view~View#t}.
 		 *
-		 * This method's context is statically bound to the `Locale` instance and should be called as a function:
+		 * This method's context is statically bound to the `Locale` instance and **always should be called as a function**:
 		 *
 		 *		const t = locale.t;
 		 *		t( 'Label' );
@@ -92,7 +92,8 @@ export default class Locale {
 		 *		t( 'Created file "%0" in %1ms.', [ fileName, timeTaken ] );
 		 *
 		 * A Message can provide a plural form using the `plural` property and a value - that should be always the first element
-		 * of the `values` array based on which the plural form of the target language should be picked.
+		 * of the `values` array based on which the plural form of the target language should be picked. That property value will
+		 * be used as a default plural translation when the translation for the target language will be missing.
 		 *
 		 *		t( { string: 'Add a space', plural: 'Add %0 spaces' }, [ spaces ] );
 		 *		t( { string: '%1 a space', plural: '%1 %0 spaces' }, [ spaces, 'Add' ] );
@@ -107,6 +108,7 @@ export default class Locale {
 		 * @method #t
 		 * @param {String|module:utils/translation-service~Message} message A message that will be localized.
 		 * @param {Array.<String>} [values] Values that should be used to interpolate the string.
+		 * @returns {String}
 		 */
 		this.t = ( message, values ) => this._t( message, values );
 	}
@@ -138,8 +140,9 @@ export default class Locale {
 	/**
 	 * Base for the {@link #t} method.
 	 *
-	 * @param {module:utils/translation-service~Message|String} message
+	 * @param {String|module:utils/translation-service~Message} message
 	 * @param {Array.<String>} [values]
+	 * @returns {String}
 	 * @private
 	 */
 	_t( message, values = [] ) {

+ 1 - 1
packages/ckeditor5-utils/src/translation-service.js

@@ -26,7 +26,7 @@ if ( !window.CKEDITOR_TRANSLATIONS ) {
  * If the message supports plural forms, make sure to provide an array with all plural forms:
  *
  *		add( 'pl', {
- *	 		'Add editor': [ 'Dodaj edytor', 'Dodaj %0 edytory', 'Dodaj %0 edytorów' ]
+ *	 		'Add spaces': [ 'Dodaj spację', 'Dodaj %0 spacje', 'Dodaj %0 spacji' ]
  * 		} );
  *
  * If you cannot import this function from this module (e.g. because you use a CKEditor 5 build), then you can