Tiqa / redux-polyglot

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

change translate() parameter #48

Open guillaumearm opened 8 years ago

guillaumearm commented 8 years ago

call translate(DummyComponent) should be forbidden.

should be call like this :

JalilArfaoui commented 8 years ago

As we discussed, I'd personally prefer that translate can be called either :

Why would you want to forbid the first one ?

guillaumearm commented 8 years ago

because it's more simple to use and to remind.

JalilArfaoui commented 8 years ago

Mmm .. why not. And do we still consider this usage :

translate({ polyglotScope: 'some.polyglot.scope' })(MyComponent)

or, in other words :

translate(options)(MyComponent)

?

It seems more complicated, but it enables us to support more option if the future, without changing signature.

JalilArfaoui commented 8 years ago

One more thing ... maybe we could choose between

If we want to maintain both, and keep using curry, to handle this call :

translate()(MyComponent)

We will have to test first arg type in translate to know if it's option or component.

This is Because of the way curry works :

const translate = curry(
  (options, component) => {
    console.log('options: '+options);
    console.log('component: '+component);
  }
);

translate()('component')('props');

output :

options: component
component: props
guillaumearm commented 8 years ago

let's go for :

guillaumearm commented 7 years ago

or translate({ polyglotScope: 'scope' })(MyComponent) as you wish.

satazor commented 7 years ago

At the moment translate()(MyComponent) doesn't work which is quite strange as I use currying as it seems to be what the community is doing (need to do translate('')(MyComponent)).

Would you accept a PR to fix this use-case and land it on the current version? As I can see, the goal is later to move the react specific functionality to react-redux-polyglot correct?

JalilArfaoui commented 7 years ago

Yes, it is a known problem. We have to uncurry translate() so that it always returns a function. Only drawback is that translate(MyComponent) won't work anymore but it won't in the future anyways so I guess it's not really a problem to do it now. PR welcome :-)

As to the future of react-redux-polyglot package, we are discussing to have it as another npm module but in the same repo.

JalilArfaoui commented 7 years ago

I've started to refactor translate : https://github.com/Tiqa/redux-polyglot/tree/feat/multi_module_refacto WIP, I'll continue tomorrow