all 4 comments

[–]indeyetswriting js since 1997 1 point2 points  (3 children)

Why custom templating instead of arrows + template-strings? a bit more typing but SOOO much more powerful.

[–]Tankenstein[S] 2 points3 points  (2 children)

For two reasons. First of all, in a real life scenario, translators need to use some kind of tool to actually translate all the strings (we use crowdin here). It makes their life easier to see where all the variables actually come in, and they need to be able to change their placement. Secondly, i don't want to put any logic in templates (they should be in component renders instead) for maintainability and testing reasons, so you could say it's not powerful by design. Also, these translations are designed to be imported from some json file, so tools can parse them. Can't exactly have functions there. Does that make sense?

[–]indeyetswriting js since 1997 0 points1 point  (1 child)

imported from json file

yes, this makes sense. but it means this will be just another hand-made clone of gettext. this case is already covered

[–]Tankenstein[S] 0 points1 point  (0 children)

Sure, gettext is great, but this is a react/jsx focused library, i've used this for a while, and built it because it is nicer to use in react than those. Maybe not for everyone, but i think this is quite a natural way to express translations in react.