Domain Specific Language and Translations in Ruby

94 views Asked by At

Thinking about a nice architecture for creating a own domains specific language in ruby, I struggeld a bit about the translation part. Say we have a event problem:

event "We made a profit" do
   income > expenditure
end

event "We have some deficite" do
   income < expenditure
end

I like to use the event descriptions "We made a profit" and "We have some deficite" as output for the User. Problem is that the description is only in english language. It should appear in different languages. I could use the i18n gem but that looks not for a solution for me.

event "event.deficite" do
   income < expenditure
end

or similiar:

event i18n.t('event.deficite') do
   income < expenditure
end

This is not a realy nice solution because it is not that readable. The whole event description get lost through the translation and destroys in my oppinion the task of the 'Domain specific language'. What is a good solution for solving this problem?

0

There are 0 answers