This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
ActiveRecord
Translations on ActiveRecord models (on class-level)
class Post < ActiveRecord::Base
validates_presence_of :country_id, :message => _('Select one fool!')
end
Someting like this did never work with GetText and can never work since at the point the class is loaded neither text_domain nor locale should be set
(no user has logged in yet). The only reason it will blow up now when using FastGettext
is that FastGettext will complain when no `text_domain/locale` is set whereas GetText gave no feedback and merrily returned the msgid.
There are 4 possible solutions I found:
- Use gettext_i18n_rails and use N_(‘Select one fool!’) OR translate the Rails I18n key: “activerecord.errors.models.post.attributes.email.presence” with e.g. “Select one fool!”
- use validate do and add the message dynamic
- use Rails I18n framework, by adding
activerecord:
errors:
models:
post:
attributes:
title:
blank: "Select one fool!"
to all config/locales/xxx.yml and remove the :message=>xxx part.
(my preferred solution since it is very simple and reduces logic)
4. Enable procs as custom messages with GeekQs monkey patch
validates_length_of :archives, :minimum => 1, :message => proc {_('Dont do that!')}







