Skip to content

Support for Dedented Multi-Line Strings #5015

@vpontis

Description

@vpontis

We have a bunch of places in our codebase where we want to define a multi-line string that will be translated.

I want to do something like the following. Note that it's indented because it's part of a function.

          // eslint-disable-next-line formatjs/enforce-id
          md: t(
            {
              defaultMessage: dedent`
                Here is a multiline email body.

                Here is another line.
              `,
              id: "email.body",
            }
          ),

I would like this to produce the string: Here is a multiline email body.\n\nHere is another line. but the FormatJS CLI doesn't support parsing this template string because it's tagged with dedent.

Are you open to having a native way of dedented strings in FormatJS?

Right now I think the alternatives are to:

  1. have weird spacing like below
  2. use a bunch of strings concated together which makes editing the strings pretty annoying
          // eslint-disable-next-line formatjs/enforce-id
          md: t(
            {
              defaultMessage: `Here is a multiline email body.

Here is another line.`,
              id: "email.body",
            }
          ),

Btw we love FormatJS, thank you! I wrote this blog post about how we use it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy