Răsfoiți Sursa

Improve way of translations usage.

Mateusz Samsel 6 ani în urmă
părinte
comite
24328eaf07

+ 4 - 0
packages/ckeditor5-word-count/lang/contexts.json

@@ -0,0 +1,4 @@
+{
+	"Words: %0": "Label showing how many words is in the editor",
+	"Characters: %0": "Label showing how many characters is in the editor"
+}

+ 28 - 10
packages/ckeditor5-word-count/src/wordcount.js

@@ -68,6 +68,26 @@ export default class WordCount extends Plugin {
 		 */
 		this.set( 'words', 0 );
 
+		/**
+		 * Label used to display words value in {@link #getWordCountContainer output contianer}
+		 *
+		 * @observable
+		 * @private
+		 * @readonly
+		 * @member {String} module:wordcount/wordcount~WordCount#_wordsLabel
+		 */
+		this.set( '_wordsLabel' );
+
+		/**
+		 * Label used to display characters value in {@link #getWordCountContainer output contianer}
+		 *
+		 * @observable
+		 * @private
+		 * @readonly
+		 * @member {String} module:wordcount/wordcount~WordCount#_charactersLabel
+		 */
+		this.set( '_charactersLabel' );
+
 		/**
 		 * A reference to a {@link module:ui/view~View view object} which contains self-updating HTML container.
 		 *
@@ -127,32 +147,30 @@ export default class WordCount extends Plugin {
 			this._outputView = new View();
 
 			if ( displayWords || displayWords === undefined ) {
-				const wordsLabel = t( 'Words' ) + ':';
+				this.bind( '_wordsLabel' ).to( this, 'words', words => {
+					return t( 'Words: %0', [ words ] );
+				} );
 
 				children.push( {
 					tag: 'div',
 					children: [
 						{
-							text: [
-								wordsLabel,
-								bind.to( 'words' )
-							]
+							text: [ bind.to( '_wordsLabel' ) ]
 						}
 					]
 				} );
 			}
 
 			if ( displayCharacters || displayCharacters === undefined ) {
-				const charactersLabel = t( 'Characters' ) + ':';
+				this.bind( '_charactersLabel' ).to( this, 'characters', words => {
+					return t( 'Characters: %0', [ words ] );
+				} );
 
 				children.push( {
 					tag: 'div',
 					children: [
 						{
-							text: [
-								charactersLabel,
-								bind.to( 'characters' )
-							]
+							text: [ bind.to( '_charactersLabel' ) ]
 						}
 					]
 				} );