如何在 Ruby on Rails 3 中允许从右到左的语言 [英] How to allow right to left languages in Ruby on Rails 3
问题描述
我有兴趣使用 Ruby on Rails 3 创建一个希伯来语网站.问题是当我将希伯来语放入我的视图时,我被告知它不受支持,我应该添加 UTF-8.
I am interested in creating a website in Hebrew using Ruby on Rails 3. The problem is when I put Hebrew into my view I am told that it is not supported and I should add UTF-8.
我已经为此工作了一段时间,但似乎找不到如何做到这一点.我也在使用 Sqlite3,我也想在那里保存希伯来语字符串.
I've been working on this for a while and I Can't seem to find how to do this. I am also using Sqlite3 and I would like to save Hebrew strings there too.
我将如何实现这一目标?
How would I achieve this?
我给出的错误代码是:
您的模板未保存为有效的 UTF-8.请在文本编辑器中指定 UTF-8 作为模板的编码,或者通过在模板的第一行插入以下内容来标记模板的编码:...
问题是我在 Notepad++ 上工作,虽然它们是 UTF-8 格式的文件,但它没有以 UTF-8 格式保存我的文件.通过更改文件格式解决.
Problem was I was working on Notepad++ which did not save my files in UTF-8 format although they were UTF-8 formated files. Solved by changing file format.
推荐答案
如果您使用的是 notepad++,请先将编码设置为以 UTF-8 编码",然后开始编码.如果您已经创建/保存了文件,那么仅更改编码类型是行不通的.您必须保留现有代码的副本,然后删除现有文件,打开记事本++,首先设置编码(UTF-8 编码),然后开始编写/复制代码.这样可以确保 utf-8 编码,并且您不必在文件顶部放置# encoding: UTF-8".
If you are using notepad++, first set the encoding to "Encode in UTF-8" and then start coding. If you have already created/saved the file then just changing the encoding type will not do. You will have to keep a copy of the existing code, then delete the existing file, open notepad++, set the encoding first(Encode in UTF-8) and then start writing/copying the code to it. This way utf-8 encoding is ensured and you won't have to put "# encoding: UTF-8" at the top of your file.
这篇关于如何在 Ruby on Rails 3 中允许从右到左的语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!