cibernox / babel-plugin-precompile-intl

Compile translations in ICU message format to invocable functions at build time
8 stars 4 forks source link

Support template literals in translations file #17

Closed crosspath closed 2 years ago

crosspath commented 2 years ago

Template literals may be useful for multiline strings in translations file.

export default {
  hello_world: `Hello, {name}.
    I want to show you the magic!
  `
}

The code above will be transformed to:

import { __interpolate } from "precompile-intl-runtime";
export default {
  hello_world: name => `Hello, ${__interpolate(name)}.
    I want to show you the magic!
  `
}

Embedded variables and expressions are not supported.

crosspath commented 2 years ago

@cibernox can you review this changeset?

cibernox commented 2 years ago

Hi! This is nice. Most people will use json files but it’s good to support this for people who really want to use than instead of /n

cibernox commented 2 years ago

I’m on a two day holiday without laptop. I will cut a new release on Wednesday!

cibernox commented 2 years ago

I published 0.4.0 of this library and 0.10.0 of svelte-intl-precompile including this new version. Thanks!