# Chinese strftime

**URL:** <https://www.ruby-forum.com/t/chinese-strftime/169741>\
**Category:** Ruby\
**Created:** [June 8, 2009, 7:25am UTC](https://www.ruby-forum.com/t/chinese-strftime/169741 "2009-06-08T07:25:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![artchrst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@artchrst](https://www.ruby-forum.com/u/artchrst)\
**Post date:** [June 8, 2009, 7:25am UTC](https://www.ruby-forum.com/t/chinese-strftime/169741/1 "2009-06-08T07:25:34Z")

</div>

Hi guys,

I need to translate the strftime into chinese.

I found a tutorial (ref:  
[Out of Computer: 讓Ruby on Rails顯示中文日期](http://out-of-pc.blogspot.com/2008/01/ruby-on-rails.html))  
`
require ‘date’
Date::ABBR_DAYNAMES.replace %w(æ—¥ ä¸€ äºŒ ä¸‰ å›› äº” å…­)
Date::DAYNAMES.replace %w(æ˜ŸæœŸæ—¥ æ˜ŸæœŸä¸€ æ˜ŸæœŸäºŒ æ˜ŸæœŸä¸‰ æ˜ŸæœŸå›› æ˜ŸæœŸäº” æ˜ŸæœŸå…­)
Date::ABBR_MONTHNAMES.replace %w(nil 1æœˆ 2æœˆ 3æœˆ 4æœˆ 5æœˆ 6æœˆ 7æœˆ 8æœˆ 9æœˆ 10æœˆ 11æœˆ
12æœˆ)
Date::MONTHNAMES.replace %w(nil ä¸€æœˆ äºŒæœˆ ä¸‰æœˆ å››æœˆ äº”æœˆ å…­æœˆ ä¸ƒæœˆ å…«æœˆ ä¹æœˆ åæœˆ åä¸€æœˆ åäºŒæœˆ)
`

It asked us to update the environment.rb.

However, I found “replace can’t modify frozen array” error when I  
restart the server.

I don’t know whether this way to update the frozen array is correct? Is  
there any better solution?

My Rails is “2.0.2”.

Thanks much  
Arthur

---

<div class="post-metadata">

**Author:** ![artchrst](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e36b37/32.png) [@artchrst](https://www.ruby-forum.com/u/artchrst)\
**Post date:** [June 8, 2009, 7:52am UTC](https://www.ruby-forum.com/t/chinese-strftime/169741/2 "2009-06-08T07:52:40Z")

</div>

well…

1.Date::ABBR\_DAYNAMES is a const var, you can do force-assignment:  
Date::ABBR\_DAYNAMES=%w[æ—¥ ä¸€ äºŒ ä¸‰ å›› äº” å…­]  
just ignore the warnings.

2.Date::ABBR\_DAYNAMES is a frezon object, you do some hacking to  
unfreeze  
it:

`

require ‘dl/struct’

module Internal
extend DL::Importable

typealias “VALUE”,nil,nil,nil,“unsigned long”
typealias “ID”,nil,nil,nil,“unsigned long”

Basic=[“long flags”,“VALUE klass”]
RBasic=struct Basic
RObject=struct(Basic+[“st_table *iv_tbl”])

FL_FREEZE=1<<10
end

class Object
def immediate?

```
[Fixnum,Symbol,NilClass,TrueClass,FalseClass].any?{ |klass| 

```

klass
===self}
19. end
20.
21. def unfreeze
22. return self if immediate?
23. Internal::RObject.new(DL::PtrData.new(self.object_id *
2)).flags&= ~
Internal::FL_FREEZE
24. self
25. end
26.
27. end
28.
29. Date::ABBR_DAYNAMES.unfreeze
30. Date::ABBR_DAYNAMES.replace…
`

But… I think it’s much easizer \*changing you local(set it to  
zh\_CN.utf-8)  
\*to make strftime return chinese.
