Tiqa / redux-polyglot

Polyglot.js bindings for Redux
MIT License
58 stars 13 forks source link

add optional parameter to translate enhancer #28

Closed guillaumearm closed 7 years ago

guillaumearm commented 7 years ago

translate enhancer could take a string named 'polyglotScope' to default browse in the phrases when use a t function :

const TranslatedComponent = translate(DummyComponent, { polyglotScope: 'catalog.misc' })

but could be this :

const TranslatedComponent = translate(DummyComponent, 'catalog.misc')

if you have a phrases object like :

{
  "catalog": {
    "misc": {
      "hello": "hi"
    }
  }
}

you just need to do a p.t('hello')

JalilArfaoui commented 7 years ago

Must be optional and non-breaking

guillaumearm commented 7 years ago

ok for this 👍 i will write unit tests soon, are you ok for publish it on npmjs without 100% coverage and without documentation ? image

JalilArfaoui commented 7 years ago

Well, coverage is still high and adoption is still low :-) ... I think you can publish.

guillaumearm commented 7 years ago

fixed in #29

guillaumearm commented 7 years ago

new implementation :

// all this lines return an enhanced Dummy component
translate(Dummy);
translate('catalog', Dummy);
translate('catalog')(Dummy);

I'm not a sure add an object instead of the string. It's more simple like this ( to use and to code ). @JalilArfaoui ? @jvincent42 ?

guillaumearm commented 7 years ago

I just remove the possibility of passing an object because I really doesn't like this.

// too heavy
{ polyglotScope: 'scope' }

(see #29)

guillaumearm commented 7 years ago

29 merged.