I translated my en.yml file to German (de.yml) and hae set DE as the
default language in environment.rb.
Everything is almost working.
My problem is that I am getting this
�
char ... instead of this
ä
on the screen displays.
I have set
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
and also tried
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
and neither produce the right result.
Have you checked your text editor encoding? Maybe it's silly to ask
about that, but some IDEs like NetBeans ocassionaly have small
problems with correct encoding
Have you checked your text editor encoding? Maybe it's silly to ask
about that, but some IDEs like NetBeans ocassionaly have small
problems with correct encoding
As far as I know, the encoding is correct. All the text editors I am
using (V-Slick, Textmate, Notepad) seem to see the same proper things.
You've got a number of problems here due to poor development decisions.
* You've declared your document as XHTML, but not used an <?xml ?>
prolog. Therefore, it will be interpreted as UTF-8 as described at
Character encodings .
* But you shouldn't be generating XHTML anyway. Browser support for
XHTML is extremely problematic. See http://hixie.ch/advocacy/xhtml for
further information. Use HTML 4 or 5 instead. If you use HTML 4, make
sure to install the html_output plugin so that Rails will not use the
XML-style <self-closing tag/> syntax, which is not valid in HTML 4.
* But even with HTML 4, I confess I don't see a single reason not to use
UTF-8 on your pages. It will handle any character you throw at it, so
you don't need to use different encodings for different languages.
- - - - - --
I have run Mongrel and Webrick and I get the same results.
I Have run Firefox and IE ... almost the same results
What's the magic formula for getting the rendering engine to think that
the page source is iso-8859-1?
Once I get that done then I will want to know how to get Ruby/Rails to
generate UTF-8 and/or Unicode.
Don't waste your time with Latin-1. Go straight to UTF-8. It will be
easier and more versatile.
You've got a number of problems here due to poor development decisions.
* You've declared your document as XHTML, but not used an <?xml ?>
prolog. Therefore, it will be interpreted as UTF-8 as described at
Character encodings .
OK ... that sounds like the problem ... I think.
* But you shouldn't be generating XHTML anyway. Browser support for
XHTML is extremely problematic. See http://hixie.ch/advocacy/xhtml for
further information. Use HTML 4 or 5 instead. If you use HTML 4, make
sure to install the html_output plugin so that Rails will not use the
XML-style <self-closing tag/> syntax, which is not valid in HTML 4.
Ok ... which do you recommend ... 4 or 5?
* But even with HTML 4, I confess I don't see a single reason not to use
UTF-8 on your pages. It will handle any character you throw at it, so
you don't need to use different encodings for different languages.
- - - - - --
I have run Mongrel and Webrick and I get the same results.
I Have run Firefox and IE ... almost the same results
What's the magic formula for getting the rendering engine to think that
the page source is iso-8859-1?
Once I get that done then I will want to know how to get Ruby/Rails to
generate UTF-8 and/or Unicode.
Don't waste your time with Latin-1. Go straight to UTF-8. It will be
easier and more versatile.
OK ... so how to I get Ruby/Rails to generate UTF-8?
Yes, that seems to be Latin-1. Why are you using Latin-1 and not
UTF-{8|16} in the first place? They are supersets of Latin-1.
I am aware of this, Marnen.
What I don't know is how to get Ruby/Rails to generate UTF-8 and/or
Unicode.
Why do you think you need to do something special here? Rails doesn't
"generate" text, for the most part; it just manipulates and hands back
what you give it.
In other words:
1. Given the ASCII string "Ralph Shnelvar", how would you have Rails
print "Ralph Shnelvar"? (Hint:you should already know the answer to
this.)
2. Given the UTF-8 string "ラルフ・シュネルヴァー", how would you have Rails print
"ラルフ・シュネルヴァー"? (Hint: the answer is the same as for #1.)
Of course, you need to set the proper encoding headers in your HTML, and
you need to have your DB encoding be UTF-8, but those are external to
Rails.
[...]
* You've declared your document as XHTML, but not used an <?xml ?>
prolog. Therefore, it will be interpreted as UTF-8 as described at
Character encodings .
OK ... that sounds like the problem ... I think.
I believe that's the immediate problem, yes.
* But you shouldn't be generating XHTML anyway. Browser support for
XHTML is extremely problematic. See http://hixie.ch/advocacy/xhtml for
further information. Use HTML 4 or 5 instead. If you use HTML 4, make
sure to install the html_output plugin so that Rails will not use the
XML-style <self-closing tag/> syntax, which is not valid in HTML 4.
Ok ... which do you recommend ... 4 or 5?
I've been using HTML 4. I don't know how well HTML 5 is supported by
browsers currently in use, but that's because I haven't done the
research yet. I'm sure others know more than I do on this point.
I tried to read through the thread but didn't actually find an answer...
Isn't the solution to make sure that en.yml is UTF-8 encoded, ie it in
UTF-8?
That's part of the solution, yes -- this is another case of Rails simply
processing the text you give it. Sorry; I should have been a bit
clearer about that.