Not really related to your question but here's a little info: strftime
knows the formatter %e which returns a single digit with a leading
space (instead of a zero) for days < 10.
Regarding your backend question: The simple backend that ships with
Rails has only one purpose: To serve the translations that Rails needs
internally in order to be backwards compatible. In most cases,
especially if you want "real" i18n/l10n in your app (for example multi-
language content), you'd want to use a different backend such as the
upcoming Globalize 2.
On Sep 14, 1:12 am, "Xavier Noria" <[EMAIL PROTECTED]> wrote:
> I am almost done with Catalan for the demo app. I switched to an .rb
> file to be able to localize dates via lambda (see below), which seemed
> an easy approach.
>
> Now for distance_in_words lambdas are not possible, so I need to write
> a custom #pluralize method in a simple backend for Catalan. I see
> there's no other backend but the default one in the demo app. I've
> seen some discussion in the archives of the mailing list about ways to
> configure #pluralize per locale. I can't just assume a
> CatalanSimpleBackend because it could interfere with the rest of
> translations in the demo app.
>
> In fact I've seen in the Rails sources that I18n.backend isn't even
> per thread, so I guess the idea is not to have a backend per locale,
> but specialized rules per locale, though currently the rules and
> backends are coupled.
>
> Is there a defined way to do this? Otherwise I'd just leave the new
> keys in ca-ES.rb and document what should be done when there's support
> for it.
>
> -- fxn
>
> module CatalanSimpleBackendUtils
> def self.month_needs_apostrophe?(month)
> # Duen apòstrof abril, agost i octubre.
> [4, 8, 10].include?(month)
> end
>
> def self.number_needs_apostophre?(n)
> if n.to_s =~ /\A11(?:\d{3})*\z/
> # 11, 11_000, 11_000_000, 11_000_000_000, etc.
> true
> elsif n.to_s =~ /\A1((?:\d{3})*)\z/ && ($1.length/3).even?
> # 1, 1_000_000, 1_000_000_000_000, etc.
> true
> else
> false
> end
> end
> end
>
> {
> :'ca-ES' => {
> :date => {
> # Aquests formats estan basats en els proposats en el fitxer
> main/ca.xml del
> # core.zip CLDR (http://unicode.org/Public/cldr/1.6.0/).
> :formats => {
> :default => "%d/%m/%Y",
> :short => "%d %b",
> :long => lambda { |date|
> month =
> CatalanSimpleBackendUtils.month_needs_apostrophe?(date.month) ? "d'%B"
> : "de %B"
> year =
> CatalanSimpleBackendUtils.number_needs_apostophre?(date.year) ? "d'%Y"
> : "de %Y"
> "#{date.day} #{month} #{year}" # explicit day to avoid
> leading zero from %d
> },
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"rails-i18n" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rails-i18n?hl=en
-~----------~----~----~----~------~----~------~--~---