virolea / rosetta

Unobstrusive Internationalization solution for Rails applications.
MIT License
53 stars 1 forks source link

Interpolation API #8

Open virolea opened 3 weeks ago

djfpaagman commented 1 week ago

I once worked on an internal tool very similar to this, cool to see you working on it as a gem!

Just wanted to drop that it probably already works out of the box if you use string substitution like so:

irb(main):001> "Hello %{name}" % { name: "Dennis" }
=> "Hello Dennis"
virolea commented 1 week ago

Thanks for the input! That's a neat trick indeed. I learnt this from the ruby-gettext docs as well.

There still some thinking needed to know how to get there. In this example

_ "%{count} message", count: 2 

count is both needed for pluralization and interpolation. I'd like to have a simple interface to translation, yet it has accomodate for several features in the background.