开发者

Rails 3 working with multiple languages

Whe开发者_JAVA技巧n working with different languages, what is the proper way to sub a string out in Rails?

Example (Czech Translation):

str = "pro více informací"
replace = "<em>více</em>"
str["více"] = replace
puts str

The problem I keep running into (and this is for multiple languages, not just Czech) is the following: IndexError (string not matched)

Is there a better way to do a string replacement? I know about gsub and sub, but both methods cause the following errors

.gsub! and gsub errors: RegexpError (invalid multibyte character)

.sub! and .sub errors: RegexpError (invalid multibyte character)


You will want to browse through this thread. Use the byte values for replacement.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜