Exclude "description" property from react-intl JSON files

CrowdIn docs mention there is built-in support for react-intl’s ICU Message JSON format, but when I build+download translations, it appears to unnecessarily include English descriptions for all strings.

Example input:

  "buttonCredits": {
    "defaultMessage": "Credits",
    "description": "Text shown on the button to open the credits message box"
  },

Produced output:

  "buttonCredits": {
    "defaultMessage": "Разработчики",
    "description": "Text shown on the button to open the credits message box"
  }

Ideally, I would like to omit the “description” property for each message (messages are just properties of the root JSON object), i.e.:

  "buttonCredits": {
    "defaultMessage": "Разработчики"
  }

I tried using the “Configurable JSON & YAML” tool, but aside from not apparently doing anything, it seems to be geared toward filtering JSON input, whereas I’m trying to filter the output.

I’ve spent quite a bit of time searching and I can’t seem to find a solution.

Anyone run into this? Got any suggestions?

Thanks!

Edit: My current plan is to just post-process the downloaded translations myself, but I suspect CrowdIn can do this for me… I just have to figure out how :slight_smile:

1 Like

Hi @jaredkrinke

Please try to disable this option in Project settingsExport

1 Like

Thanks! Unfortunately, that didn’t appear to have any effect on the “Build & Download” output.

1 Like

It looks like regex app can do the trick and customize exported files:

Install the app => go to the project settings => File Processors and start setting up the post-processor.

Rules:

Remember to check “Unescape special characters”:

We need to search for (note there should be 4 spaces before description but Discourse doesn’t show it below in preview…):
",\n "description": "(.*?)"\n

and replace it with:
"\n

Hope it helps!

2 Likes

This sounds like what I need, but I can’t seem to get it to do anything. Does this run when I use the Translations → Build & Download button? Or do I need to go through some other entry point?

I setup a rule to change “description” to “hello”, and it doesn’t appear to modify the output JSON file at all, so I’m kind of stumped.

1 Like

Ok, I figured it out. Adding a file processor or changing its configuration only affects translation files that have subsequently been updated, so I wasn’t seeing any effect because I wasn’t also modifying any translations.

Honestly, that’s not how I’d expect it to work. I wonder if that’s expected? Regardless, it’s easy to work around.

For the record, I ended up using a slightly different configuration:

2 Likes

Hi Jared,

Glad to hear that you’ve figured it out and everything works fine

Let us know if you need further assistance!

1 Like

Turns out some of my strings with values don’t work with the above regular expression, so I wouldn’t recommend anyone else copy it since it’s not robust!

I’ll just post-process the files myself.