Hello, I would like to store my strings, messages, etc. in some "property" file like in Java. Is there any way how to store these messages outside the ruby code? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
jsd wrote:> Hello, > I would like to store my strings, messages, etc. in some "property" file > like in Java. Is there any way how to store these messages outside the > ruby code?You want to store some strings in global variable, so you can access them in your ruby code? I don''t understand, please explain -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I want to store my strings, flash/error messages in some external file,
e.g. /app/helpers/my_strings.messages
In this file I want to have something like :
error.msg.login.admin="You need to login before...."
error.msg.field.required="This field is required,......"
generally:
(key="value")
Later, I want to access this file with my messages through some object :
e.g. Messages.read("error.msg.login.admin") - and this will return
value
associated to specific key (analogy of Messages.properties file in
Java).
Is this possible in RoR applications?
Jamal Soueidan wrote:> jsd wrote:
>> Hello,
>> I would like to store my strings, messages, etc. in some
"property" file
>> like in Java. Is there any way how to store these messages outside the
>> ruby code?
>
> You want to store some strings in global variable, so you can access
> them in your ruby code?
>
> I don''t understand, please explain
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On Jun 2, 6:25 am, jsd <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello, > I would like to store my strings, messages, etc. in some "property" file > like in Java. Is there any way how to store these messages outside the > ruby code?I assume you''re wanting to do this as part of some i18n or l10n effort. But even if not, the following should apply. I don''t have a really good straight answer for you, but you should check out the discussion on this page: http://wiki.rubyonrails.org/rails/pages/Internationalization As well as this forum: http://www.ruby-forum.com/forum/20 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If you''re looking for localizing you rails application, look here:
http://wiki.rubyonrails.org/rails/pages/InternationalizationComparison
But if you want a simple file with messages, you can use YAML...
-- my_strings.messages file (It must conform to YAML file format):
error.msg.login.admin: You need to login before....
error.msg.field.required: This field is required,......
-- ruby code to load it
require "yaml"
messsage = File.open(''my_strings.messages'') { |yaml_file|
YAML::load(yaml_file) }
-- and use it like a hash (It''s a Hash indeed!)
messsage[''error.msg.login.admin'']
HTH
- H
On 6/2/07, jsd
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> I want to store my strings, flash/error messages in some external file,
> e.g. /app/helpers/my_strings.messages
> In this file I want to have something like :
>
> error.msg.login.admin="You need to login before...."
> error.msg.field.required="This field is required,......"
>
> generally:
> (key="value")
>
> Later, I want to access this file with my messages through some object :
> e.g. Messages.read("error.msg.login.admin") - and this will
return value
> associated to specific key (analogy of Messages.properties file in
> Java).
>
> Is this possible in RoR applications?
>
>
>
>
>
>
>
> Jamal Soueidan wrote:
> > jsd wrote:
> >> Hello,
> >> I would like to store my strings, messages, etc. in some
"property" file
> >> like in Java. Is there any way how to store these messages outside
the
> >> ruby code?
> >
> > You want to store some strings in global variable, so you can access
> > them in your ruby code?
> >
> > I don''t understand, please explain
>
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--
Husein Choroomi
Yucca Intelligence Development
http://www.YuccaHQ.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
jeroen.knoops-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jun-03 12:41 UTC
Re: Storing strings outside the ruby code.
Hello I wanted a simular thing. Property files in JAVA were great, but they don''t seem to match Rails Testing Framework. Therefor I made a model called ActiveProperty. This will store values as a key / value pair by using an ActiveRecord. Once stored, the property is available as simple method. ApplicationProperty.test -> "no key/value pair" ApplicationProperty.test = "This is a test" -> "This is a test" ApplicationProperty.test -> "This is a test" See http://johnnybusca.blogspot.com/ for the source code with tests how to use. By storing these properties as activerecords, you can use the active_property.yml fixture to override the values for test purposes. This is very handy for testing file manupulations. Best regards, Jeroen On Jun 2, 12:25 pm, jsd <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hello, > I would like to store my strings, messages, etc. in some "property"file > like in Java. Is there any way how to store these messages outside the > ruby code? > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Do you mean like in YAML or some such? I think AWDWR or Ruby for Rails describes marshalling objects so they can be stored in a file. Bill -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---