summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/webhelper/smoke-tests/webview.js6
-rw-r--r--webhelper/webhelper.js7
2 files changed, 10 insertions, 3 deletions
diff --git a/test/webhelper/smoke-tests/webview.js b/test/webhelper/smoke-tests/webview.js
index c3c7dd5..fe2a655 100644
--- a/test/webhelper/smoke-tests/webview.js
+++ b/test/webhelper/smoke-tests/webview.js
@@ -52,7 +52,7 @@ using the &lt;input&gt;\'s ID</a> \
<p><a href="endless://addStars?id=starspan">I want \
stars!</a> <span id="starspan"/></p> \
\
-<p>This is text that will be translated: <span name="translatable">Hello, \
+<p>This is text that will be italicized: <span name="translatable">Hello, \
world!</span></p> \
\
</body> \
@@ -62,6 +62,10 @@ const TestApplication = new Lang.Class({
Name: 'TestApplication',
Extends: WebHelper.Application,
+ _translationFunction: function(string) {
+ return string.italics();
+ },
+
/* *** ACTIONS AVAILABLE FROM THE WEB VIEW *** */
_webActions: {
diff --git a/webhelper/webhelper.js b/webhelper/webhelper.js
index 7ec17a6..ccce9e7 100644
--- a/webhelper/webhelper.js
+++ b/webhelper/webhelper.js
@@ -78,8 +78,11 @@ const Application = new Lang.Class({
// WebKit.DOMNode
let element = translatable.item(i);
- // TODO here is where we would do the translation
- element.inner_html = '<i>' + element.inner_text + '</i>';
+ // Translate the text
+ if(typeof this._translationFunction !== 'function')
+ throw new Error("No suitable translation function was found. " +
+ "Did you forget to set '_translationFunction' on your app?");
+ element.inner_html = this._translationFunction(element.inner_text);
}
}
});