2014-03-20 20:55:59 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/language.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: global
|
|
|
|
|
|
|
|
The $tw.Language() manages translateable strings
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/*
|
|
|
|
Create an instance of the language manager. Options include:
|
|
|
|
wiki: wiki from which to retrieve translation tiddlers
|
|
|
|
*/
|
|
|
|
function Language(options) {
|
|
|
|
options = options || "";
|
|
|
|
this.wiki = options.wiki || $tw.wiki;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-09-08 09:41:27 +00:00
|
|
|
Return a wikified translateable string. The title is automatically prefixed with "$:/language/"
|
2014-03-20 20:55:59 +00:00
|
|
|
Options include:
|
|
|
|
variables: optional hashmap of variables to supply to the language wikification
|
|
|
|
*/
|
|
|
|
Language.prototype.getString = function(title,options) {
|
|
|
|
options = options || {};
|
|
|
|
title = "$:/language/" + title;
|
|
|
|
return this.wiki.renderTiddler("text/plain",title,{variables: options.variables});
|
|
|
|
};
|
|
|
|
|
2015-09-08 09:41:27 +00:00
|
|
|
/*
|
|
|
|
Return a raw, unwikified translateable string. The title is automatically prefixed with "$:/language/"
|
|
|
|
*/
|
|
|
|
Language.prototype.getRawString = function(title) {
|
|
|
|
title = "$:/language/" + title;
|
|
|
|
return this.wiki.getTiddlerText(title);
|
|
|
|
};
|
|
|
|
|
2014-03-20 20:55:59 +00:00
|
|
|
exports.Language = Language;
|
|
|
|
|
|
|
|
})();
|