Hello i18n community of rails. I’ve been programming RoR for a few
years now, and want to test my chops contributing to some open source
projects, I have a special interest in i18n and have an Idea, though i
wanted to get some feedback on the first the validity (and usability)
of the idea, and then second on the potential implementation (caveats,
major problems, etc.).
What I’m interested in doing is creating an backend generating rake
task and to create the default key pair automatically so the key is
the actual sentence in your html.erb file.
For example in my code rather than have t(".welcome_message") and then
in my en.yml have a key value pair, i could put something akin to
t(".Welcome to my Web page") which after rake could generate the key
value pair similar to this:
welcome_to_my_web_page: “Welcome to my Web page”
Do you think such functionality would be useful to someone getting
started with i18n, or to a veteran having the ability to modify the
key value pair and view the changes in the html.erb at the same time
(keeping things a little more dry) ?
If you would desire this type of functionality what types of technical
hurdles would I expect to face? I wouldn’t want special characters in
my keys, and I also wouldn’t want the keys themselves to be entire
paragraphs, are there any other caveats you see?
If this has already been tried let me know, again i’m just getting
started “giving back” to the community, so this may not be the right
idea, and/or project. Whatever your opinions or thoughts are please
share them!
Yes, that is useful. Since I just got off my Globalize 1 addiction, I
am missing the alternative, less cumbersome way of coding I18n apps.
What I came up with was a plugin that combines a database backend for
I18n, fallbacks and some of the func. you mentioned, e.g.
de:
“Hello World”: “Hallo Welt!”
Feel free to poke around:
http://github.com/jfesslmeier/globalize_bridge
Greetings,
Juergen
Hi Richard,
Nice to see that you’re willing to contribute.
The idea you present remind me a bit of gettext. I like the detection
part, but I’m not that comfortable with using real texts as keys.
They’re fragile and I don’t think you should keep all the strings
inside your views. Or are you suggesting that the rake file changes
the view from <%= t(".Welcome to my webpage") %> to <%=
t(".welcome_to_my_webpage") as well? I don’t know if that is handy.
You are also going to have problems with longer strings, which will
clog your locale files.
I believe Zigzag Chen already did something similar with his
ready_for_i18n gem. Unfortunately, he died recently.
Remember: i18n is one of the harder problems in programming, so be
prepared for some setbacks.
Good luck!
Hi
I have implemented a similar solution using an added string method
(to_local(key))
That means I just write “Welcome to my Web page”.to_local(:view) or
any other key header, using a sing a text mate bundle (using sven’s
bundle as a starting point) that generates a key of the kind you want
in all locals
if you are interested I can send you the code
Hans M.
St: Larsgatan 50, 58224 Linköping, Sweden
Phone: +46708371202
8 jun 2010 kl. 18.26 skrev Richard S.:
It sounds like this area is open up to quite a bit of interpretation,
this was excellent feedback, and it looks like i’ll have to do some
homework before I start as there maybe some existing solutions. Hans,
do you have your code posted on github by any chance?
–
Richard
I agree that my solutions has some problems, but i really simplify the
t ask if you have a lot of strings
The main problem is that you generate new keys each time you change
the string and ends upp with many unused keys
This problem can then be solved by an existing rake task
Mybe some combination would be useful.
I there are long string I use som key instead and if there a a lot of
text I use different html files
Hans M.
St: Larsgatan 50, 58224 Linköping, Sweden
Phone: +46708371202
8 jun 2010 kl. 19.38 skrev Iain H.: