Skip to content

Polish long date format translation with grammatical cases #284

Open
Holek opened this Issue Dec 11, 2012 · 3 comments

3 participants

@Holek
Holek commented Dec 11, 2012

In Polish, proper long date format is %d %B %Y, which I changed in Localeapp.

The problem occurs with date.month_names, where i18n-rails takes month names, which are translated (correctly) in nominative case (e.g. "styczeń", "luty", etc.).

Proper case for long date formats in Polish is to use genitive case (e.g. "stycznia", "lutego", etc.)

For example, instead of "12 styczeń 2010" it should be "12 stycznia 2010".

What I would propose is another translation, for example: date.long_month_names, which would have corresponding names for long month name translations.

We could get around a grammatical case issue and also allow other languages to follow this convention.

@tjku
tjku commented Sep 17, 2014

I solved this by creating file /locale/datetime.pl.rb with content:

{
  :pl => {
    :date => {
      :month_names => lambda { |date_or_time, opts|
        if opts[:format] =~ /(%d|%-d|%e)(.*)(%B)/
          [nil, 'stycznia', 'lutego', 'marca', 'kwietnia', 'maja', 'czerwca',
          'lipca', 'sierpnia', 'września', 'października', 'listopada', 'grudnia']
        else
          [nil, 'styczeń', 'luty', 'marzec', 'kwiecień', 'maj', 'czerwiec',
          'lipiec', 'sierpień', 'wrzesień', 'październik', 'listopad', 'grudzień']
        end
      }
    }
  }
}

This solution is based on gem polish.

@Holek
Holek commented Sep 30, 2014

:+1: That looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.