jenseng / react-i18nliner

translate="yes" all the things
MIT License
45 stars 15 forks source link

some files mangled during preprocessing #9

Closed jenseng closed 9 years ago

jenseng commented 9 years ago

this may be a recast printing bug, or it may be due to #1, or both ... i've got a file w/ some jsx like so

      <div>
        <LayoutItemHeader type="survey">
          ...
          <Block name="layout--item-header__actions">
            <SurveyHeaderActions
              survey={this.props.survey}
              permissions={this.props.permissions}
              media={this.state.media}
              handleClickPreview={this.handleClickPreview}
              handleDuplicate={this.handleDuplicate} />
          </Block>
        </LayoutItemHeader>

        <div className="survey-distributions large-content-area centered padding-trl-m-desktop padding-none-mobile">
          <div key="subtitle" className="clearfix padding-tb-l padding-xs-mobile grey-bg-mobile">
            <h2 className="margin-b-s left">
              {I18n.t("Distributions")}
            </h2>
            <DistributeBox groupSearch={this.props.groupSearch} surveyId={this.props.survey.id}>
              <button type="button" className="add-btn">
                <Text>+ <span className="add-btn__text">Distribute</span></Text>
              </button>
            </DistributeBox>
          </div>

          <DistributionList {...distributionProps} />
        </div>
      </div>

it gets preprocessed into this:

      <div>
        <LayoutItemHeader type="survey">
          ...
          <Block name="layout--item-header__actions">
            <SurveyHeaderActions
              survey={this.props.survey}
              permissions={this.props.permissions}
              me dia={t<I18n.ComponentInterpolator
                  string={I18n.t("+ *Distribute*")}
                  wrappers={{
                    "*": s.state.media}$1
                  }}>$1</I18n.ComponentInterpolator>
              handleClickPreview={this.handleClickPreview}
              handleDuplicate={this.handleDuplicate} />
          </Block>
        </LayoutItemHeader>

        <div className="survey-distributions large-content-area centered padding-trl-m-desktop padding-none-mobile">
          <div key="subtitle" className="clearfix padding-tb-l padding-xs-mobile grey-bg-mobile">
            <h2 className="margin-b-s left">
              {I18n.t("Distributions")}
            </h2>
            <DistributeBox groupSearch={this.props.groupSearch} surveyId={this.props.survey.id}>
              <button type="button" className="add-btn">
                <Text>+ <span className="add-btn__text">Distribute</span></Text>
              </button>
            </DistributeBox>
          </div>

          <DistributionList {...distributionProps} />
        </div>
      </div>

<Text> is an autoTranslateTag, and it does get preprocessed ... sort of, but in the wrong place. note the mangled media attribute inside <SurveyHeaderActions> ... totally broken

jenseng commented 9 years ago

of course, i am using babel-acorn and the babel-core patches to ast-types (via custom i18nliner plugin that sets recastOptions), and that's totes unsupported. so this is kind of uncharted territory :-/

this problem does not exist when using vanilla recast (w/ esprima-fb)

jenseng commented 9 years ago

This was due to bad loc.end data, confirmed it's no longer a problem with this fix applied.