【问题标题】:Telescope form labels - where do they come from?望远镜形式的标签——它们来自哪里?
【发布时间】:2015-07-19 03:21:50
【问题描述】:

我在 Telescope 中找不到任何明显表明自动表单标签来自何处的内容。我可以看到架构中没有标签(至少对于 Posts 来说不是),至少在 Posts autoform 调用中没有什么明显的......

{{> quickForm collection="Posts" id="submitPostForm" template="bootstrap3-horizontal" input-col-class="controls" type="method" meteormethod="submitPost" fields=postFields}}

...我找不到将标签传递给自动表单的任何字段集或其他明显的方法。因此,作为示例,来自 Posts 架构的“createdAt”在表单中显示时最终具有“Created At”的显示标签 - 这种“转换”在哪里以及如何发生?

TIA!

【问题讨论】:

    标签: meteor telescope


    【解决方案1】:

    表单标签使用tap:i18n 包进行国际化。因此,您可以在每个包的/i18n 目录中为您当前语言的相应*.i18n.json 文件中找到它们的翻译。

    【讨论】:

      【解决方案2】:

      没关系...我在深入挖掘之后找到了答案...有一个国际化方法扩展了 SimpleSchema 并在附加处理此问题的架构之前调用:

      SimpleSchema.prototype.internationalize = function () {
        var schema = this._schema;
      
        _.each(schema, function (property, key) {
          if (!property.label) {
            schema[key].label = function () {
              // if property is nested ("telescope.email"), only consider the last part ("email")
              if (key.indexOf(".") !== -1) {
                key = _.last(key.split("."));
              }
              return i18n.t(key);
            };
          }
        });
        return this;
      };
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-09
        • 2021-07-01
        • 1970-01-01
        • 1970-01-01
        • 2012-05-30
        相关资源
        最近更新 更多