Skip to content

Commit

Permalink
Tradotto 06_ActionView fino alla fine
Browse files Browse the repository at this point in the history
  • Loading branch information
grigio committed Jun 17, 2008
1 parent c998f28 commit 5c4ca77
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
29 changes: 14 additions & 15 deletions text/06_ActionView/05_number_helper.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@

### number\_to\_currency

Il metodo **number\_to\_currency**
The **number\_to\_currency** method now accepts the **:format** option as a parameter,letting us to format the method's returning value. In earlier versions, when we had to format values for our local currency, we needed to include a space in front of **:unit** option to make the output format correct. See the examples:

# R$ is the symbol for Brazilian currency
number_to_currency(9.99, :separator => ",", :delimiter => ".", :unit => "R$")
# => "R$9,99″
Il metodo **number\_to\_currency** ora accetta l'opzione **:format** come parametro, quindi è possibile formattare il valore di ritorno del metodo. Nelle versioni passate, quando si doveva formattare la valuta locale, bisognava includere uno spazio davanti l'opzione **:unit** per avere il formato dell'output corretto. Osservare gli esempi:

# € è il simbolo dell'Euro
number_to_currency(9.99, :separator => ",", :delimiter => ".", :unit => "€")
# => "€9,99″

number_to_currency(9.99, :format => "%u %n", :separator => ",",
:delimiter => ".", :unit => "R$")
# => "R$ 9,99″
:delimiter => ".", :unit => "")
# => " 9,99″

Besides that, we can customize in other forms, for example:
Oltre a questo, si possono fare altre personalizzazioni:

number_to_currency(9.99, :format => "%n in Brazilian reais", :separator => ",",
:delimiter => ".", :unit => "R$")
# => "9,99 em reais"
number_to_currency(9.99, :format => "%n in euro", :separator => ",",
:delimiter => ".", :unit => "")
# => "9,99 in euro"

When creating your own formatting string, you can use the following parameters:
Quando si creano delle stringhe formattate è possibile usare i seguenti parametri:

%u For the currency
%n For the number
%u Per la valuta
%n Per il numero
14 changes: 7 additions & 7 deletions text/06_ActionView/06_text_helper.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

### excerpt

The **excerpt** method is a helper to find a word inside a phrase and return an abreviation of that phrase with the number of given characters as parameters before and after the word, adding, when necessary the "…". Look an example:
Il metodo **excerpt** è un helper che trova una parola dentro un testo e restituisce un'abbreviazione di quel testo con il numero di caratteri, dati come parametro, prima e dopo la parola. Se necessario verranno aggiunti "…". Esempio:

excerpt('This is an example', 'an', 5)
# => "…s is an examp…"
But the problem it was bugged. If you count, you'll see the method returned 6 chars and not 5. This bug was fixed. Look the example of the correct output for this method:

Il problema è che è sbagliato. Il metodo ha restituito 6 caratteri e non 5. Questo bug è stato corretto. Ecco l'output corretto di questo metodo:

excerpt('This is an example', 'an', 5)
# => "…s is an exam…"

###simple\_format

Il metodo **simple\_format** principalmente riceve come parametro un qualsiasi testo e lo formatta in modo semplice in **HTML**. Prende il testo e sostituisce a capo (\n) con il tag **HTML** "< br />" e quando si hanno due a capo consecutivi (\n\n) separa il testo nel paragrafo con il tag "< p>".

The **simple\_format** method basically receives as a parameter any text and formats it in a simple way to **HTML**. It takes the text and replaces line breaks (\n) by **HTML** tag "< br />". And when we have two line breaks one after other (\n\n) it separates the text in paragraphs using "< p>"tag.

In Rails 2.1 this method received an additional parameter. Besides text, we are going to be able to inform which **HTML** attributes we would like "< p>" tag had. Look the examples:
In Rails 2.1 questo metodo supporta ulteriori parametri. Oltre al testo, si può specificare quali attributi **HTML** vogliamo che il tag "< p>" abbia. Esempio:

simple_format("Hello Mom!", :class => 'description')
# => "<p class=’description’>Hello Mom!</p>"

The **HTML** attributes will be added in all "< p>" tags created by the method.
Gli attributi **HTML** saranno aggiunti in tutti i tag "< p>" creati dal metodo.

0 comments on commit 5c4ca77

Please sign in to comment.