D
D
DarkCoder2011-11-14 23:42:08
Ruby on Rails
DarkCoder, 2011-11-14 23:42:08

Russian in Ruby on Rails?

RoR does not accept Russian string literals in the controller file:

SyntaxError in PagesController#about<br/>
<br/>
/home/alex/rails/test/app/controllers/pages_controller.rb:3: invalid multibyte char (US-ASCII)<br/>
/home/alex/rails/test/app/controllers/pages_controller.rb:3: invalid multibyte char (US-ASCII)<br/>
/home/alex/rails/test/app/controllers/pages_controller.rb:3: syntax error, unexpected $end, expecting keyword_end<br/>
 @title = &quot;Главная&quot;<br/>
 ^<br/>
Rails.root: /home/alex/rails/test<br/>

env dump:
GATEWAY_INTERFACE: &quot;CGI/1.1&quot;<br/>
HTTP_ACCEPT: &quot;text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8&quot;<br/>
HTTP_ACCEPT_CHARSET: &quot;windows-1251,utf-8;q=0.7,*;q=0.3&quot;<br/>
HTTP_ACCEPT_ENCODING: &quot;gzip,deflate,sdch&quot;<br/>
HTTP_ACCEPT_LANGUAGE: &quot;ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4&quot;<br/>
HTTP_CACHE_CONTROL: &quot;max-age=0&quot;<br/>
REMOTE_ADDR: &quot;127.0.0.1&quot;<br/>
REMOTE_HOST: &quot;localhost&quot;<br/>
SERVER_NAME: &quot;localhost&quot;<br/>
SERVER_PROTOCOL: &quot;HTTP/1.1&quot;

Tell me what can be done

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rinat Shaikhutdinov, 2011-11-15
@DarkCoder

Read this: Rails Internationalization (I18n) API and don't write string literals in controllers or models anymore.
In general, take a look at this screencast: Railscasts: #30 Pretty Page Title and read the comments to it to learn how to organize the work with page titles correctly (“rails-way”).

P
philpirj, 2011-11-17
@philpirj

In the first line of the file write:

# coding: utf-8

G
Georgy Khromchenko, 2011-11-15
@Mox

This is something related to the ruby ​​1.9.x branch, there is no such thing under 1.8.7.
Moreover, I remember that if you generate a project from under 1.9.x right away, then this does not happen.
Does anyone have experience of migrating Russian-language projects from 1.8.7 to 1.9.x?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question