| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- class translation {
- #content;
- translated;
- /**
- * This create new translation. Translation store content of the
- * translation, make avairable to format translated phrase and also
- * store that translation was found in the phrasebook.
- *
- * @param {string} content - Content of the translation.
- * @param {bool} translated - True when translation could be found.
- */
- constructor(content, translated = true) {
- if (typeof(content) !== "string") {
- throw new TypeError("Translated content must be string.");
- }
- if (typeof(translated) !== "boolean") {
- throw new TypeError("Result of translation must be boolean.");
- }
- this.#content = content;
- this.translated = translated;
- }
- /**
- * This convert transiation to string.
- *
- * @returns {string} - Content of the translation.
- */
- toString() {
- return this.#content;
- }
- /**
- * @returns {string} - Content of the translation.
- */
- get text() {
- return this.#content;
- }
- /**
- * @returns {bool} - True when translation was found, false when not.
- */
- get valid() {
- return this.translated;
- }
- }
- exports.translation = translation;
|