Agile Web Development with Rails by unknow

Agile Web Development with Rails by unknow

Author:unknow
Language: eng
Format: epub, pdf
Tags: Pragmatic Bookshelf
ISBN: 9781934356548
Publisher: The Pragmatic Bookshelf, LLC (205844)
Published: 0101-01-01T06:00:00+00:00


* * *

Figure 36. Ready to take your money—in Spanish

All looks good until we hit the Realizar Pedido button prematurely and see Figure 37, ​Translation missing​. The error messages that Active Record produces can also be translated; what we need to do is supply the translations:

rails32/depot_s/config/locales/es.yml

​es:​

​​

​ activerecord:​

​ errors:​

​ messages:​

​ inclusion: "no está incluido en la lista"​

​ blank: "no puede quedar en blanco"​

​ errors:​

​ template:​

​ body: "Hay problemas con los siguientes campos:"​

​ header:​

​ one: "1 error ha impedido que este %{model} se guarde"​

​ other: "%{count} errores han impedido que este %{model} se guarde"​

Note that messages with counts typically have two forms: errors.template.header. one is the message that is produced when there is one error, and errors.template. header.other is produced otherwise. This gives the translators the opportunity to provide the correct pluralization of nouns and to match the verbs with the nouns.

Since we once again made use of HTML entities, we will want these error messages to be displayed as is (or in Rails parlance, raw). We will also need to translate the error messages. So again, we modify the form:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.