[extensions-web] i18n: mark translatable strings in mustache templates with x-gettext tag.
- From: Yuri Konotopov <ykonotopov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [extensions-web] i18n: mark translatable strings in mustache templates with x-gettext tag.
- Date: Tue, 22 Jan 2019 03:49:01 +0000 (UTC)
commit b81d74c7ba0ab609ec4fd65f8e9c3670528c6aee
Author: Yuri Konotopov <ykonotopov gnome org>
Date: Tue Jan 22 00:42:51 2019 +0400
i18n: mark translatable strings in mustache templates with x-gettext tag.
sweettooth/static/js/template.js | 11 ++++++++---
.../static/js/templates/extensions/comments_list.mst | 6 +++---
.../js/templates/extensions/error_report_template.mst | 14 +++++++-------
.../static/js/templates/extensions/info_contents.mst | 2 +-
sweettooth/static/js/templates/extensions/uninstall.mst | 2 +-
5 files changed, 20 insertions(+), 15 deletions(-)
---
diff --git a/sweettooth/static/js/template.js b/sweettooth/static/js/template.js
index 7e47d76..c08cd99 100644
--- a/sweettooth/static/js/template.js
+++ b/sweettooth/static/js/template.js
@@ -8,7 +8,7 @@
(at your option) any later version.
*/
-define(['mustache'], function(Mustache) {
+define(['jquery', 'mustache'], function($, Mustache) {
return {
load: (templateFile, parentRequire, onload, config) => {
parentRequire(['text!templates/' + templateFile + '.mst'], (loadedTemplate) => {
@@ -17,10 +17,15 @@ define(['mustache'], function(Mustache) {
return templateFile;
},
render: (model, partials) => {
- return Mustache.render(loadedTemplate, model, partials);
+ let html = $(Mustache.render(loadedTemplate, model,
partials));
+ // TODO: better/faster way to preparse templates?
+ html.find('x-gettext').replaceWith(function() {
+ return gettext($(this).text());
+ });
+ return html;
},
template: () => {
- return loadedTemplate
+ return loadedTemplate;
}
});
});
diff --git a/sweettooth/static/js/templates/extensions/comments_list.mst
b/sweettooth/static/js/templates/extensions/comments_list.mst
index 9e73bb2..2915ccd 100644
--- a/sweettooth/static/js/templates/extensions/comments_list.mst
+++ b/sweettooth/static/js/templates/extensions/comments_list.mst
@@ -1,7 +1,7 @@
{{#comments}}
<div class="comment">
{{#is_extension_creator}}
- <div class="extension-creator-badge">Author</div>
+ <div class="extension-creator-badge"><x-gettext>Author</x-gettext></div>
{{/is_extension_creator}}
<img src="{{gravatar}}" class="gravatar">
<div class="rating-author">
@@ -16,9 +16,9 @@
<hr>
{{/comments}}
{{^show_all}}
-<p class="show-all">Show more reviews</p>
+<p class="show-all"><x-gettext>Show more reviews</x-gettext></p>
{{/show_all}}
{{^comments}}
- <p>There are no comments. Be the first!</p>
+ <p><x-gettext>There are no comments. Be the first!</x-gettext></p>
{{/comments}}
diff --git a/sweettooth/static/js/templates/extensions/error_report_template.mst
b/sweettooth/static/js/templates/extensions/error_report_template.mst
index fba4dab..0a0d0e5 100644
--- a/sweettooth/static/js/templates/extensions/error_report_template.mst
+++ b/sweettooth/static/js/templates/extensions/error_report_template.mst
@@ -1,12 +1,12 @@
-What's wrong?
+<x-gettext>What's wrong?</x-gettext>
-What have you tried?
+<x-gettext>What have you tried?</x-gettext>
-Automatically detected errors:
+<x-gettext>Automatically detected errors</x-gettext>:
{{#errors}}
{{.}}
@@ -14,10 +14,10 @@ Automatically detected errors:
================
{{/errors}}
{{^errors}}
-GNOME Shell Extensions did not detect any errors with this extension.
+<x-gettext>GNOME Shell Extensions did not detect any errors with this extension.</x-gettext>
{{/errors}}
-Version information:
+<x-gettext>Version information</x-gettext>:
- Shell version: {{sv}}
- Extension version: {{#ev}}{{ev}}{{/ev}}{{^ev}}Unknown{{/ev}}
+ <x-gettext>Shell version</x-gettext>: {{sv}}
+ <x-gettext>Extension version</x-gettext>:
{{#ev}}{{ev}}{{/ev}}{{^ev}}<x-gettext>Unknown</x-gettext>{{/ev}}
diff --git a/sweettooth/static/js/templates/extensions/info_contents.mst
b/sweettooth/static/js/templates/extensions/info_contents.mst
index c7b022e..c9f8fdc 100644
--- a/sweettooth/static/js/templates/extensions/info_contents.mst
+++ b/sweettooth/static/js/templates/extensions/info_contents.mst
@@ -18,5 +18,5 @@
</div>
</div>
<div style="clear: both"></div>
-<div class='system-extension' title='System extension should be uninstalled using package manager. See
«About» page for more details.'>System extension</div>
+<div class='system-extension' title='System extension should be uninstalled using package manager. See
«About» page for more details.'><x-gettext>System extension</x-gettext></div>
<p class="description">{{first_line_of_description}}</p>
diff --git a/sweettooth/static/js/templates/extensions/uninstall.mst
b/sweettooth/static/js/templates/extensions/uninstall.mst
index 8a350ce..2a671fd 100644
--- a/sweettooth/static/js/templates/extensions/uninstall.mst
+++ b/sweettooth/static/js/templates/extensions/uninstall.mst
@@ -1 +1 @@
-You uninstalled <b>{{name}}</b>.
+<x-gettext>You uninstalled</x-gettext> <b>{{name}}</b>.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]