Code Monkey home page Code Monkey logo

polish's Introduction

Polish

travis-ci stillmaintained

Polish language support for Ruby on Rails.

Adds correct polish pluralization and better date formats. Also includes support for standalone months. ("%B %Y" should be Grudzień 2009, but "%d. %B %Y" should be 24. grudnia 2009).

Based on Russian by yaroslav.

Install

Warning: as of version 0.1.0, polish is only tested with Rails 3 and Bundler. Use with caution, might give unexpected results.

To add Polish to your Rails app, simply add it to your Gemfile:

gem "polish", ">= 0.1.0"

Additionally, if you change the backend of I18n, you will need to make sure it includes the Pluralization module:

I18n.backend.class.send(:include, I18n::Backend::Pluralization)

What it does

The main feature of polish is fixing the date formats. It does that by setting the date.month_names and date.day_names translations to Procs that can detect the proper form.

Polish also adds correct pluralization rules.

Overrides

Translations and date formats can be overridden in config/locales/pl.yml

polish's People

Contributors

grk avatar mostlyobvious avatar sufler avatar zlw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

polish's Issues

Błąd dla distance_of_time_in_words_to_now

Taki kod:

<%= distance_of_time_in_words_to_now(event.finish_at) %>

Zwraca błąd:

translation data {:other=>"około {{count}} godzin", :one=>"około godziny"} can not be used with :count => 4

event.finish_at to pole datetime w bazie z datą w przyszłości. Dla daty w przeszłości działa ok

problem z Rails 3

przy walidacjach w Rails 3, widać stary styl (z Rails 2) w tłumaczeniach:

nie może być puste, jest za krótkie (minimalnie {{count}} znaki)

W związku z tym, chciałem użyć branch'a rails3.
Wpis w Gemfile:

gem 'polish', :git => 'git://github.com/grk/polish.git', :branch => 'rails3'

Przy bundle install dostaję taki oto warning:

Using polish (0.0.4) from git://github.com/grk/polish.git (at rails3) 
polish at /home/schiza/.bundler/ruby/1.9.1/polish-cfab4d5c11b8 did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
["init.rb", "lib/polish/backend", "lib/polish/backend/advanced.rb", "lib/vendor", "lib/vendor/i18n", "lib/vendor/i18n/CHANGELOG.textile", "lib/vendor/i18n/i18n.gemspec", "lib/vendor/i18n/lib", "lib/vendor/i18n/lib/i18n", "lib/vendor/i18n/lib/i18n/backend", "lib/vendor/i18n/lib/i18n/backend/base.rb", "lib/vendor/i18n/lib/i18n/backend/cache.rb", "lib/vendor/i18n/lib/i18n/backend/chain.rb", "lib/vendor/i18n/lib/i18n/backend/fallbacks.rb", "lib/vendor/i18n/lib/i18n/backend/gettext.rb", "lib/vendor/i18n/lib/i18n/backend/pluralization.rb", "lib/vendor/i18n/lib/i18n/backend/simple.rb", "lib/vendor/i18n/lib/i18n/exceptions.rb", "lib/vendor/i18n/lib/i18n/gettext.rb", "lib/vendor/i18n/lib/i18n/helpers", "lib/vendor/i18n/lib/i18n/helpers/gettext.rb", "lib/vendor/i18n/lib/i18n/locale", "lib/vendor/i18n/lib/i18n/locale/fallbacks.rb", "lib/vendor/i18n/lib/i18n/locale/tag", "lib/vendor/i18n/lib/i18n/locale/tag/parents.rb", "lib/vendor/i18n/lib/i18n/locale/tag/rfc4646.rb", "lib/vendor/i18n/lib/i18n/locale/tag/simple.rb", "lib/vendor/i18n/lib/i18n/locale/tag.rb", "lib/vendor/i18n/lib/i18n/string.rb", "lib/vendor/i18n/lib/i18n.rb", "lib/vendor/i18n/MIT-LICENSE", "lib/vendor/i18n/Rakefile", "lib/vendor/i18n/README.textile", "lib/vendor/i18n/test", "lib/vendor/i18n/test/all.rb", "lib/vendor/i18n/test/api", "lib/vendor/i18n/test/api/basics.rb", "lib/vendor/i18n/test/api/interpolation.rb", "lib/vendor/i18n/test/api/lambda.rb", "lib/vendor/i18n/test/api/link.rb", "lib/vendor/i18n/test/api/localization", "lib/vendor/i18n/test/api/localization/date.rb", "lib/vendor/i18n/test/api/localization/date_time.rb", "lib/vendor/i18n/test/api/localization/lambda.rb", "lib/vendor/i18n/test/api/localization/time.rb", "lib/vendor/i18n/test/api/pluralization.rb", "lib/vendor/i18n/test/api/translation.rb", "lib/vendor/i18n/test/backend", "lib/vendor/i18n/test/backend/cache", "lib/vendor/i18n/test/backend/cache/cache_test.rb", "lib/vendor/i18n/test/backend/chain", "lib/vendor/i18n/test/backend/chain/api_test.rb", "lib/vendor/i18n/test/backend/chain/chain_test.rb", "lib/vendor/i18n/test/backend/fallbacks", "lib/vendor/i18n/test/backend/fallbacks/api_test.rb", "lib/vendor/i18n/test/backend/fallbacks/fallbacks_test.rb", "lib/vendor/i18n/test/backend/pluralization", "lib/vendor/i18n/test/backend/pluralization/api_test.rb", "lib/vendor/i18n/test/backend/pluralization/pluralization_test.rb", "lib/vendor/i18n/test/backend/simple", "lib/vendor/i18n/test/backend/simple/all.rb", "lib/vendor/i18n/test/backend/simple/api_test.rb", "lib/vendor/i18n/test/backend/simple/lookup_test.rb", "lib/vendor/i18n/test/backend/simple/setup.rb", "lib/vendor/i18n/test/backend/simple/translations_test.rb", "lib/vendor/i18n/test/fixtures", "lib/vendor/i18n/test/fixtures/locales", "lib/vendor/i18n/test/fixtures/locales/de.po", "lib/vendor/i18n/test/fixtures/locales/en.rb", "lib/vendor/i18n/test/fixtures/locales/en.yml", "lib/vendor/i18n/test/fixtures/locales/plurals.rb", "lib/vendor/i18n/test/gettext", "lib/vendor/i18n/test/gettext/api_test.rb", "lib/vendor/i18n/test/gettext/backend_test.rb", "lib/vendor/i18n/test/i18n_exceptions_test.rb", "lib/vendor/i18n/test/i18n_load_path_test.rb", "lib/vendor/i18n/test/i18n_test.rb", "lib/vendor/i18n/test/locale", "lib/vendor/i18n/test/locale/fallbacks_test.rb", "lib/vendor/i18n/test/locale/tag", "lib/vendor/i18n/test/locale/tag/rfc4646_test.rb", "lib/vendor/i18n/test/locale/tag/simple_test.rb", "lib/vendor/i18n/test/string_test.rb", "lib/vendor/i18n/test/test_helper.rb", "lib/vendor/i18n/test/with_options.rb", "lib/vendor/i18n/vendor", "lib/vendor/i18n/vendor/po_parser.rb", "lib/vendor/i18n/VERSION"] are not files

A przy próbie uruchomienia serwera:

$ rails s

    /var/lib/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require': no such file to load -- action_view_ext/helpers/date_helper (LoadError)
    from /var/lib/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `block in require'
    from /var/lib/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `block in load_dependency'
    from /var/lib/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /var/lib/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /var/lib/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
    from /home/schiza/.bundler/ruby/1.9.1/polish-cfab4d5c11b8/lib/polish.rb:9:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
    from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
    from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `block in require'
    from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
    from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
    from /var/lib/gems/1.9.1/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
    from /home/schiza/ruby/praca/sonik/config/application.rb:7:in `<top (required)>'
    from /var/lib/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:28:in `require'
    from /var/lib/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:28:in `block in <top (required)>'
    from /var/lib/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
    from /var/lib/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Czy da się jakoś poprawnie użyć tego brancha? Czy po prostu jest w tej chwili jakiś bug? I jak naprawić ten problem z {{count}} ?

activerecord.yml proste zmiany

Proponuję kilke poprawek w pliku activerecord.yml
wrong_length:
one: "jest nieprawidłowej długości (powinna wynosić 1 znak)"
few: "jest nieprawidłowej długości (powinna wynosić %{count} znaki)"
other: "jest nieprawidłowej długości (powinna wynosić %{count} znaków)"

oraz literówka do poprawienia:
less_than: "musi być mniejsze niż %{count}"

can not be used with :count => 5

got issue:

I18n::InvalidPluralizationData

translation data {:many=>"jest za krótkie (minimalnie {{count}} znaków)", :one=>"jest za krótkie (minimalnie {{count}} znak)", :few=>"jest za krótkie (minimalnie {{count}} znaki)"} can not be used with :count => 5

for code :

POST_CODE_LENGTH = 5..20
validates_length_of :post_code, :within => POST_CODE_LENGTH

handling genders in error header

Is there a possibility to manage genders in error header?
For example:
this code
template:
header:
one: "%{model} nie został zachowany z powodu jednego błędu"
few: "%{model} nie został zachowany z powodu %{count} błędów"
other: "%{model} nie został zachowany z powodu %{count} błędów"

for zwierzę model will generate

"zwierzę nie został zachowany z powodu jednego błędu"
That's wrong in polish.

How to handle this?
What I want is model specific header probably.

Now I'm working with template text like this:
template:
header:
one: "Nie można zapisać z powodu jednego błędu"
few: "Nie można zapisać z powodu %{count} błędów"
other: "Nie można zapisać z powodu %{count} błędów"

It's working and it's polish correct but there is no model name.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.