浏览代码

Modify search results translations

* use named place holders in translation tag with multiple values
John R. Supplee 4 年之前
父节点
当前提交
7a5aa469cd
共有 3 个文件被更改,包括 19 次插入10 次删除
  1. 1 8
      client/components/main/globalSearch.jade
  2. 17 1
      client/components/main/globalSearch.js
  3. 1 1
      i18n/en.i18n.json

+ 1 - 8
client/components/main/globalSearch.jade

@@ -20,14 +20,7 @@ template(name="globalSearch")
       else if hasResults.get
       else if hasResults.get
         .global-search-dueat-list-wrapper
         .global-search-dueat-list-wrapper
           h1
           h1
-            if $eq resultsCount.get 0
-              | {{_ 'no-cards-found' }}
-            else if $eq resultsCount.get 1
-              | {{_ 'one-card-found' }}
-            else if $eq resultsCount.get totalHits.get
-              | {{_ 'n-cards-found' resultsCount.get }}
-            else
-              | {{_ 'n-n-of-n-cards-found' 1 resultsCount.get totalHits.get }}
+            = resultsHeading
           if queryErrors.get
           if queryErrors.get
             div
             div
               each msg in errorMessages
               each msg in errorMessages

+ 17 - 1
client/components/main/globalSearch.js

@@ -52,7 +52,7 @@ BlazeComponent.extendComponent({
       const results = Cards.globalSearch(this.queryParams);
       const results = Cards.globalSearch(this.queryParams);
       const sessionData = SessionData.findOne({ userId: Meteor.userId() });
       const sessionData = SessionData.findOne({ userId: Meteor.userId() });
       // eslint-disable-next-line no-console
       // eslint-disable-next-line no-console
-      console.log('sessionData:', sessionData);
+      // console.log('sessionData:', sessionData);
       // console.log('errors:', results.errors);
       // console.log('errors:', results.errors);
       this.totalHits.set(sessionData.totalHits);
       this.totalHits.set(sessionData.totalHits);
       this.resultsCount.set(results.cards.count());
       this.resultsCount.set(results.cards.count());
@@ -83,6 +83,22 @@ BlazeComponent.extendComponent({
     return messages;
     return messages;
   },
   },
 
 
+  resultsHeading() {
+    if (this.resultsCount.get() === 0) {
+      return TAPi18n.__('no-cards-found');
+    } else if (this.resultsCount.get() === 1) {
+      return TAPi18n.__('one-card-found');
+    } else if (this.resultsCount.get() === this.totalHits.get()) {
+      return TAPi18n.__('n-cards-found', this.resultsCount.get());
+    }
+
+    return TAPi18n.__('n-n-of-n-cards-found', {
+      start: 1,
+      end: this.resultsCount.get(),
+      total: this.totalHits.get(),
+    });
+  },
+
   events() {
   events() {
     return [
     return [
       {
       {

+ 1 - 1
i18n/en.i18n.json

@@ -873,7 +873,7 @@
   "no-cards-found": "No Cards Found",
   "no-cards-found": "No Cards Found",
   "one-card-found": "One Card Found",
   "one-card-found": "One Card Found",
   "n-cards-found": "%s Cards Found",
   "n-cards-found": "%s Cards Found",
-  "n-n-of-n-cards-found": "%s-%s of %s Cards Found",
+  "n-n-of-n-cards-found": "__start__-__end__ of __total__ Cards Found",
   "operator-board": "board",
   "operator-board": "board",
   "operator-board-abbrev": "b",
   "operator-board-abbrev": "b",
   "operator-swimlane": "swimlane",
   "operator-swimlane": "swimlane",