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.
精彩评论