mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-15 23:07:18 +00:00
Make more core strings be translateable
Now we’re translating strings that occur in JavaScript modules. Partially fixing #491
This commit is contained in:
37
core/modules/language.js
Normal file
37
core/modules/language.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/*\
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
Return a single translateable string. The title is automatically prefixed with "$:/language/"
|
||||
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});
|
||||
};
|
||||
|
||||
exports.Language = Language;
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user