In my ruby code , I try to put all the output messages in one file for translation purposes, in case the client want to change the return messages it will be organized in one file.
lets assume that I have the config file with name messages.rb at root, I include it with my main.rb ruby process something like :
require "#{ROOT_PATH}/config/messages.rb"
The file will contain something like :
class Messages
MSG = {
:msg1 => "Account successfully created",
:msg2 => "Hello"
}
end
Now when I call msg1 lets say in main.rb I do something like :
puts Messages::MSG[:msg2]
But as you can see it is not convient it to use it this way specially that in most of te cases I will need to include some data something like
puts Messages::MSG[:msg2] + @username
I'm sure there is some sort of dynamic conf file or other way to do it right and would appreciate it if you can provide me with the best way to do so and with the best performance .
Thanks