1

私はフランス語でアプリケーションを持っています。アプリケーションを実行してフォームをテストすると、「Email : should look like an email address.」という英語のメッセージが表示されます。「fr.yml」を保存すると、「Email : ne semble pas être une adresse email」というメッセージがフランス語で表示されます。これは authlogic のフィールドにのみ表示され、先月も同じコードで機能していました。

これは application.rb によるものです:

  require File.expand_path('../boot', __FILE__)

  # Pick the frameworks you want:
  require "active_record/railtie"
  require "action_controller/railtie"
  require "action_mailer/railtie"
  require "active_resource/railtie"
  require "sprockets/railtie"
  # require "rails/test_unit/railtie"

  if defined?(Bundler)
    # If you precompile assets before deploying to production, use this line
    Bundler.require(*Rails.groups(:assets => %w(development test)))
    # If you want your assets lazily compiled in production, use this line
    # Bundler.require(:default, :assets, Rails.env)
  end

  module Onopia
    class Application < Rails::Application
      # Settings in config/environments/* take precedence over those specified here.
      # Application configuration should go into files in config/initializers
      # -- all .rb files in that directory are automatically loaded.

      # Custom directories with classes and modules you want to be autoloadable.
      # config.autoload_paths += %W(#{config.root}/extras)

      # Only load the plugins named here, in the order given (default is alphabetical).
      # :all can be used as a placeholder for all plugins not explicitly named.
      # config.plugins = [ :exception_notification, :ssl_requirement, :all ]

      # Activate observers that should always be running.
      # config.active_record.observers = :cacher, :garbage_collector, :forum_observer

      # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
      # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
      # config.time_zone = 'Central Time (US & Canada)'

      # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
      # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
      config.i18n.default_locale = :fr

      # Configure the default encoding used in templates for Ruby 1.9.
      config.encoding = "utf-8"

      # Configure sensitive parameters which will be filtered from the log file.
      config.filter_parameters += [:password]

      # Enable the asset pipeline
      config.assets.enabled = true

      # Version of your assets, change this if you want to expire all your assets
      config.assets.version = '1.1'

      # Configure generators values. Many other options are available,
      # be sure to check the documentation.
      #config.generators do |g|
      #  g.test_framework :rspec, :fixture => false
      #end

      config.action_mailer.default_url_options = { :host => 'localhost:3000' }
      config.assets.initialize_on_precompile = false
    end

    if defined?(Bundler)
      Bundler.require(:default, :assets, Rails.env)
    end
  end

これは私の宝石リストです:

    actionmailer (3.2.2)
    actionpack (3.2.2)
    activeadmin (0.4.3)
    activemodel (3.2.2)
    activerecord (3.2.2)
    activeresource (3.2.2)
    activesupport (3.2.2)
    addressable (2.2.7)
    archive-tar-minitar (0.5.2)
    arel (3.0.2)
    authlogic (3.1.0)
    autotest-rails (4.1.1)
    bcrypt-ruby (3.0.1)
    blankslate (2.1.2.4)
    bourbon (1.4.0)
    builder (3.0.0)
    bundler (1.1.2)
    capybara (1.1.2)
    capybara-firebug (0.0.10)
    capybara-webkit (0.9.0)
    childprocess (0.3.1)
    coderay (1.0.6)
    coffee-rails (3.2.2)
    coffee-script (2.2.0)
    coffee-script-source (1.2.0)
    columnize (0.3.6)
    cucumber (1.1.9)
    cucumber-rails (1.2.1)
    database_cleaner (0.7.0)
    devise (2.0.4)
    diff-lcs (1.1.3)
    email_spec (1.2.1)
    erubis (2.7.0)
    execjs (1.3.0)
    factory_girl (2.3.2)
    factory_girl_rails (1.4.0)
    fastercsv (1.5.4)
    ffi (1.0.11)
    formtastic (2.1.1)
    galetahub-simple_captcha (0.1.3)
    gherkin (2.9.3)
    has_scope (0.5.1)
    heroku (2.24.0)
    hike (1.2.1)
    i18n (0.6.0)
    inherited_resources (1.3.1)
    jbuilder (0.4.0)
    journey (1.0.3)
    jquery-rails (2.0.2)
    json (1.6.6)
    kaminari (0.13.0)
    launchy (2.0.5)
    linecache19 (0.5.12)
    mail (2.4.4)
    meta_search (1.1.3)
    metaclass (0.0.1)
    method_source (0.7.1)
    mime-types (1.18)
    mocha (0.10.0)
    multi_json (1.0.4)
    netrc (0.7.1)
    nifty-generators (0.4.6)
    nokogiri (1.5.2)
    orm_adapter (0.0.7)
    pg (0.13.2)
    pickle (0.4.10)
    polyamorous (0.5.0)
    polyglot (0.3.3)
    prawn (0.8.4)
    prawn-core (0.8.4)
    prawn-layout (0.8.4)
    prawn-security (0.8.4)
    pry-nav (0.2.0)
    pry-remote (0.1.1)
    rack (1.4.1)
    rack-cache (1.2)
    rack-ssl (1.3.2)
    rack-test (0.6.1)
    rails (3.2.2)
    railties (3.2.2)
    rake (0.9.2.2)
    rdoc (3.12)
    responders (0.9.1)
    rest-client (1.6.7)
    rspec (2.8.0)
    rspec-core (2.8.0)
    rspec-expectations (2.8.0)
    rspec-mocks (2.8.0)
    rspec-rails (2.8.1)
    ruby-debug-base19 (0.11.25)
    ruby-debug19 (0.11.6)
    ruby_core_source (0.1.5)
    rubyzip (0.9.7)
    sass (3.1.15)
    sass-rails (3.2.5)
    selenium-webdriver (2.20.0)
    shoulda-context (1.0.0)
    shoulda-matchers (1.0.0)
    simple_form (2.0.1)
    simplecov (0.5.4)
    simplecov-html (0.5.3)
    simplecov-rcov (0.2.3)
    slop (2.4.4)
    spork (0.8.5)
    sprockets (2.1.2)
    sqlite3 (1.3.5)
    term-ansicolor (1.0.7)
    thor (0.14.6)
    tilt (1.3.3)
    treetop (1.4.10)
    tzinfo (0.3.33)
    uglifier (1.2.4)
    warden (1.1.1)
    xpath (0.1.4)
    ZenTest (4.5.0)

そして、これは私の fr.yml です:

    # French translations for Ruby on Rails
    # by Christian Lescuyer (christian@flyingcoders.com)
    # contributors:
    # - Sebastien Grosjean - ZenCocoon.com
    # - Bruno Michel - http://github.com/nono
    # - Tsutomu Kuroda - http://github.com/kuroda (t-kuroda@oiax.jp)

    fr:
      date:
        formats:
          default: "%d/%m/%Y"
          short: "%e %b"
          long: "%e %B %Y"
        day_names:
          - lundi
          - mardi
          - mercredi
          - jeudi
          - vendredi
          - samedi
          - dimanche
        abbr_day_names:
          - lun
          - mar
          - mer
          - jeu
          - ven
          - sam
          - dim
        month_names:
          - ~
          - janvier
          - février
          - mars
          - avril
          - mai
          - juin
          - juillet
          - août
          - septembre
          - octobre
          - novembre
          - décembre
        abbr_month_names:
          - ~
          - jan.
          - fév.
          - mar.
          - avr.
          - mai
          - juin
          - juil.
          - août
          - sept.
          - oct.
          - nov.
          - déc.
        order:
          - :day
          - :month
          - :year

      time:
        formats:
          default: "%d %B %Y %H:%M:%S"
          short: "%d %b %H:%M"
          long: "%A %d %B %Y %H:%M"
        am: 'am'
        pm: 'pm'

      datetime:
        distance_in_words:
          half_a_minute: "une demi-minute"
          less_than_x_seconds:
            zero: "moins d'une seconde"
            one: "moins d'une seconde"
            other: "moins de %{count} secondes"
          x_seconds:
            one: "1 seconde"
            other: "%{count} secondes"
          less_than_x_minutes:
            zero: "moins d'une minute"
            one: "moins d'une minute"
            other: "moins de %{count} minutes"
          x_minutes:
            one: "1 minute"
            other: "%{count} minutes"
          about_x_hours:
            one: "environ une heure"
            other: "environ %{count} heures"
          x_days:
            one: "1 jour"
            other: "%{count} jours"
          about_x_months:
            one: "environ un mois"
            other: "environ %{count} mois"
          x_months:
            one: "1 mois"
            other: "%{count} mois"
          about_x_years:
            one: "environ un an"
            other: "environ %{count} ans"
          over_x_years:
            one: "plus d'un an"
            other: "plus de %{count} ans"
          almost_x_years:
            one: "presqu'un an"
            other: "presque %{count} ans"
        prompts:
          year: "Année"
          month: "Mois"
          day: "Jour"
          hour: "Heure"
          minute: "Minute"
          second: "Seconde"

      number:
        format:
          separator: ","
          delimiter: " "
          precision: 3
          significant: false
          strip_insignificant_zeros: false
        currency:
          format:
            format: "%n %u"
            unit: "€"
            separator: ","
            delimiter: " "
            precision: 2
            significant: false
            strip_insignificant_zeros: false
        percentage:
          format:
            delimiter: ""
        precision:
          format:
            delimiter: ""
        human:
          format:
            delimiter: ""
            precision: 2
            significant: true
            strip_insignificant_zeros: true
          storage_units:
            format: "%n %u"
            units:
              byte:
                one: "octet"
                other: "octets"
              kb: "ko"
              mb: "Mo"
              gb: "Go"
              tb: "To"
          decimal_units:
            format: "%n %u"
            units:
              unit: ""
              thousand: "millier"
              million: "million"
              billion: "milliard"
              trillion: "billion"
              quadrillion: "million de milliards"

      support:
        array:
          words_connector: ", "
          two_words_connector: " et "
          last_word_connector: " et "
        select:
          prompt: "Veuillez sélectionner"

      helpers:
        select:
          prompt: "Veuillez sélectionner"
        submit:
          create: "Créer un %{model}"
          update: "Modifier ce %{model}"
          submit: "Enregistrer ce %{model}"

      attributes:
        created_at: "Créé le"
        updated_at: "Modifié le"

      errors:
        format: "%{attribute} : %{message}"
        messages: &errors_messages
          inclusion: "n'est pas inclus(e) dans la liste"
          exclusion: "n'est pas disponible"
          invalid: "n'est pas valide"
          confirmation: "ne concorde pas avec la confirmation"
          accepted: "doit être accepté(e)"
          empty: "doit être rempli(e)"
          blank: "doit être rempli(e)"
          too_long: "est trop long (pas plus de %{count} caractères)"
          too_short: "est trop court (au moins %{count} caractères)"
          wrong_length: "ne fait pas la bonne longueur (doit comporter %{count} caractères)"
          not_a_number: "n'est pas un nombre"
          not_an_integer: "doit être un nombre entier"
          greater_than: "doit être supérieur à %{count}"
          greater_than_or_equal_to: "doit être supérieur ou égal à %{count}"
          equal_to: "doit être égal à %{count}"
          less_than: "doit être inférieur à %{count}"
          less_than_or_equal_to: "doit être inférieur ou égal à %{count}"
          odd: "doit être impair"
          even: "doit être pair"
        template: &errors_template
          header:
            one: "Impossible d'enregistrer ce %{model} : 1 erreur"
            other: "Impossible d'enregistrer ce %{model} : %{count} erreurs"
          body: "Veuillez vérifier les champs suivants : "

      activerecord:
        errors:
          messages:
            taken: "n'est pas disponible"
            record_invalid: "La validation a échoué : %{errors}"
            <<: *errors_messages
          template:
            <<: *errors_template
          full_messages:
            format: "%{attribute} %{message}"

        attributes:
          models:
            user: Utilisateur
            account: "Compte"
            bank: "Banque"
          user:
            username: Pseudo
            email: Email
            password: Mot de passe
          account:
            login: "Identifiant"
            password: "Mot de passe"
            account_type_id: "Type"

      home:
        successfully_updated: "Votre mot de passe a été modifié"
        index:
          submit: "Valider"
          remember: 'Me rappeler mon not de passe'

      authlogic:
        error_messages:
          login_blank: "doit être rempli(e)"
          login_not_found: "n'est pas valide"
          login_invalid: "doit contenir uniquement des lettres, des nombres, des espaces, et .-_@ s'il vous plaît."
          consecutive_failed_logins_limit_exceeded: La limit de tentatives de connexion consectuives a été dépassée. Le compte à été désactivé.
          email_invalid: ne semble pas être une adresse email
          password_blank: "doit être rempli(e)"
          password_invalid: "n'est pas valide"
          not_active: "Votre compte n'est pas actif"
          not_confirmed: "Votre compte n'est pas confirmé"
          not_approved: "Votre compte n'est pas approuvé"
          no_authentication_details: "Vous n'avez pas fournis les details pour vous authentifier."
        models:
          user: "Utilisateur"
          user_session: "Session utilisateur"
        attributes:
          user_session:
            username: Pseudo
            login: Login
            email: Email
            password: "Mot de passe"
            remember_me: "se souvenir de moi"

      simple_captcha:
        label: "Veuillez saisir le code ci-dessous:"
        message:
          user: "le code de sécurité n'est pas valide"

手伝って頂けますか?

ありがとう。

更新:私はこの関数でファイル「authlogic/acts_as_authentic/email.rb」にブレークポイントを置きました:

    "validates_format_of_email_field_options" 

I18n.t('error_messages.email_invalid') をテストすると、次のメッセージが表示されます。

    translation missing: en.authlogic.error_messages.email_invalid 

したがって、authlogic はデフォルトのメッセージを受け取ります。これを試すと:

    Onopia::Application.config.i18n.default_locale 

私は持っている :

    :fr

理解できない。たぶん、私のロケールの前に authlogic がロードされますか???

4

1 に答える 1

1

application.rb、現在のロケールも設定します。

i18n.config.default_locale = :fr
i18n.config.locale = :fr

理由を聞かないでください:)

于 2012-07-26T21:35:51.183 に答える