2011-08-04 2 views
1

레일즈 3.0.9에서 슬로베니아어 번역을 사용하여 t('errors', :count => 2)을 사용하고 싶습니다. 슬로베 언 언어를위한 특별한 복수형 인 "2 napaki"를 반환하고 싶습니다.레일즈 3 및 슬로베니아 복수형

나는 로케일/sl.yml을 생성하고이 코드가있다 :

sl: 
    error: 
    one: %{count} napaka 
    two: %{count} napaki 
    other: %{count} napak 

을하지만이 작동하지 않습니다.

답변

1

번역을 config/locales/sl.yml에 입력했는지 확인하십시오.

class Application < Rails::Application 
    ... 
    config.i18n.default_locale = :sl 
    ... 
end 

: 기본 로케일을 설정해야합니다

# More rules in this file: https://github.com/svenfuchs/i18n/blob/master/test/test_data/locales/plurals.rb 
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization) 
{ 
    :'sl' => { :i18n => { :plural => { :rule => lambda { |n| [1].include?(n % 100) && ![11].include?(n % 100) ? :one : [2].include?(n % 100) && ![12].include?(n % 100) ? :two : [3, 4].include?(n % 100) && ![13, 14].include?(n % 100) ? :few : :other }}}} 
} 

당신의 application.rb에서 : 당신은 또한 파일 설정/로케일/plurals.rb를 만들 필요가 내부에 다음 코드를 놓을 게요 이러한 변경을 한 후에 서버를 다시 시작하십시오. :one, :two, :other 외에 :few의 숫자는 3, 4, ...

have a look at this gist도 정확하게 물어볼 수 있습니다.

+0

작동합니다. 고마워요! – pr0factor87