Skip to content

Releases: alexdrel/i18n-react

Better literal syntax

17 May 22:28
Compare
Choose a tag to compare

Allows matching number of backticks (with optional whitespace) to form a literal. This allows quoting of the backtick pairs: ``` `` ``` => `` .

Passing MDText in the React 16.3+ Context

31 Mar 15:59
Compare
Choose a tag to compare

MDText object can be passed around using new official react context API.

import { MDText } from 'i18n-react';
let MDTextContext = React.createContext();
let Texts = new MDText({...});

<MDTextContext.Provider value={Texts}>
    <MDTextContext.Consumer>{ (T) =>
      <T.span text="path.to.string" />
    }</MDTextContext.Consumer>
</MDTextContext.Provider>

See updated examples/yaml for complete example.

Adds the ability to provide a function for notFound or translation dictionary

11 Nov 00:24
Compare
Choose a tag to compare

notFound property can be either a string, or a function returning a string.
If it is a string, then it will be returned as is any time a key is missing.
If you provide a function, then the function will be run with the missing key
and context as arguments.

T.setTexts(translations, {
  notFound: key => `**${key}**` // will render <strong>SomeKey</strong>
})

Translation dictionaries can be extended with functions (as in notFound).

T.setTexts({
    a: 'A',
    n: (_key, ctx) => ctx ? `Number ${ctx}` : '',
  });
T.translate('a')) // 'A'
T.translate('n', { context: 9 })) // 'Number 9'

Fix for Gratuitous Literals

15 Oct 21:32
Compare
Choose a tag to compare

Fix #33 (Gratuitous literal)

Literal quotes \`\` in V1 syntax

07 Oct 20:38
Compare
Choose a tag to compare

New `` syntax `` (in V1 only) to disable MD processing.

React 16+ required

07 Oct 01:14
Compare
Choose a tag to compare

As React now allows fragments and strings in render the default behavior of <T.text> changed not to wrap the output into <span> when tag property is not specified.

New MD syntax

02 Aug 18:53
Compare
Choose a tag to compare

The new MD flavor (aligned with github's Markdown) is added : V1. Opt-in for this release, will become default in the next major release.
V1 introduces strike and underline, and rehabilitates <b> and <i> tags.

  em: "an *italic* style"
  i: "an _italic_ style"
  strong: "a **bold** move"
  b: "a __bold__ move"
  u: "an ~underlined~ word"
  strike: "a ~~strike~~ out"

To opt-in for the new syntax:

let T = new MDText(texts, { MDFlavor: 1 });
// or for the singelton
T.setTexts(require('../texts/texts-en.yml'), { MDFlavor: 1, notFound: 'NA' });

MDText notFound property is deprecated - please switch to constructor or serTexts options.

Typescript 1.8 compatibilty workaround

29 Jul 11:53
Compare
Choose a tag to compare

Disabled export typing of TS 2.0 for compatibility with currently stable Typescript 1.8

React 15.2 and @typings

07 Jul 21:48
Compare
Choose a tag to compare
Unknown Prop Warning

React 15.2 is preparing to stop filtering HTML properties - the feature that i18n relied upon for preventing interpolation variables from leaking into the DOM.

Thus new syntax for passing variables is introduced:

<T.span text={{ key: "greeting", myName: "i18n-react" }}/>
/* replaces */
<T.span text="greeting" myName="i18n-react"/>

All tags passing to T.* anything beside text, tag and context properties have to be updated or React 15.2 will cry annoyingly.

typescript 2.0 / ts@next typings

Updated package.json contains all the info for the new typescript to get typings automatically.

ES6 ready

07 Jul 21:49
Compare
Choose a tag to compare
  • ES6 style export (use default export explicitly for commonJS/UMD)
  • Stateless react components (shouldComponentUpdate optimization removed)
  • Default export (T above) no longer can be used as a react component (use T.text or T.span instead)