开发者

Rails 3 working with multiple languages

开发者 https://www.devze.com 2023-01-25 15:27 出处:网络
Whe开发者_JAVA技巧n working with different languages, what is the proper way to sub a string out in Rails?

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

精彩评论

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