|
|
@@ -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 = [] ) {
|