1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

Make lazy loading message be translateable

This commit is contained in:
Jermolene 2015-09-08 10:41:27 +01:00
parent f405a89b28
commit ecdae4ceff
3 changed files with 34 additions and 15 deletions

View File

@ -20,6 +20,7 @@ Encryption/RepeatPassword: Repeat password
Encryption/PasswordNoMatch: Passwords do not match Encryption/PasswordNoMatch: Passwords do not match
Encryption/SetPassword: Set password Encryption/SetPassword: Set password
InvalidFieldName: Illegal characters in field name "<$text text=<<fieldName>>/>". Fields can only contain lowercase letters, digits and the characters underscore (`_`), hyphen (`-`) and period (`.`) InvalidFieldName: Illegal characters in field name "<$text text=<<fieldName>>/>". Fields can only contain lowercase letters, digits and the characters underscore (`_`), hyphen (`-`) and period (`.`)
LazyLoadingWarning: <p>Loading external text from ''<$text text={{!!_canonical_uri}}/>''</p><p>If this message doesn't disappear you may be using a browser that doesn't support external text in this configuration. See http://tiddlywiki.com/#ExternalText</p>
MissingTiddler/Hint: Missing tiddler "<$text text=<<currentTiddler>>/>" - click {{$:/core/images/edit-button}} to create MissingTiddler/Hint: Missing tiddler "<$text text=<<currentTiddler>>/>" - click {{$:/core/images/edit-button}} to create
OfficialPluginLibrary: Official ~TiddlyWiki Plugin Library OfficialPluginLibrary: Official ~TiddlyWiki Plugin Library
PluginReloadWarning: Please save {{$:/core/ui/Buttons/save-wiki}} and reload {{$:/core/ui/Buttons/refresh}} to allow changes to plugins to take effect PluginReloadWarning: Please save {{$:/core/ui/Buttons/save-wiki}} and reload {{$:/core/ui/Buttons/refresh}} to allow changes to plugins to take effect

View File

@ -22,7 +22,7 @@ function Language(options) {
} }
/* /*
Return a single translateable string. The title is automatically prefixed with "$:/language/" Return a wikified translateable string. The title is automatically prefixed with "$:/language/"
Options include: Options include:
variables: optional hashmap of variables to supply to the language wikification variables: optional hashmap of variables to supply to the language wikification
*/ */
@ -32,6 +32,14 @@ Language.prototype.getString = function(title,options) {
return this.wiki.renderTiddler("text/plain",title,{variables: options.variables}); return this.wiki.renderTiddler("text/plain",title,{variables: options.variables});
}; };
/*
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);
};
exports.Language = Language; exports.Language = Language;
})(); })();

View File

@ -28,20 +28,9 @@ var WikiParser = function(type,text,options) {
this.wiki = options.wiki; this.wiki = options.wiki;
var self = this; var self = this;
// Check for an externally linked tiddler // Check for an externally linked tiddler
if($tw.browser && options._canonical_uri) { if($tw.browser && (text || "") === "" && options._canonical_uri) {
$tw.utils.httpRequest({ this.loadRemoteTiddler(options._canonical_uri);
url: options._canonical_uri, text = $tw.language.getRawString("LazyLoadingWarning");
type: "GET",
callback: function(err,data) {
if(!err) {
var tiddlers = self.wiki.deserializeTiddlers(".tid",data,self.wiki.getCreationFields())
if(tiddlers) {
self.wiki.addTiddlers(tiddlers);
}
}
}
});
text = "Loading external text from ''" + options._canonical_uri + "''\n\nIf this message doesn't disappear you may be using a browser that doesn't support external text in this configuration. See http://tiddlywiki.com/#ExternalText";
} }
// Initialise the classes if we don't have them already // Initialise the classes if we don't have them already
if(!this.pragmaRuleClasses) { if(!this.pragmaRuleClasses) {
@ -79,6 +68,27 @@ var WikiParser = function(type,text,options) {
// Return the parse tree // Return the parse tree
}; };
/*
*/
WikiParser.prototype.loadRemoteTiddler = function(url) {
var self = this;
$tw.utils.httpRequest({
url: url,
type: "GET",
callback: function(err,data) {
if(!err) {
var tiddlers = self.wiki.deserializeTiddlers(".tid",data,self.wiki.getCreationFields());
$tw.utils.each(tiddlers,function(tiddler) {
tiddler["_canonical_uri"] = url;
});
if(tiddlers) {
self.wiki.addTiddlers(tiddlers);
}
}
}
});
};
/* /*
*/ */
WikiParser.prototype.setupRules = function(proto,configPrefix) { WikiParser.prototype.setupRules = function(proto,configPrefix) {