0

I'm having some problems having html tags correctly loaded in my Rails 3.2 app, and have no clue why. I managed to get it working for one flash message, but I am not managing to do it with a confirmation message.

Any ideas ?

My pt.yml file extract :

 buttons:
    accept_terms: "Aceito os termos e condições"
    save: "Gravar"
    delete: "Apagar"
    add_new_receipt: "+"
    add_receipt_label: "Clique para adicionar novo recibo"
    download_all_html: "Tem a certeza que deseja descarregar todos os ficheiros correspondentes à pesquisa? <br />
    Esta operação pode demorar algum tempo, dependendo do número de ficheiros e da sua ligação à Internet "

my view code:

<%= link_to (t :download_all, scope: "pages.home.customers"), user_download_all_path(user_id:current_user.id, is_retailer: params[:controller]=='suppliers' ? true : false), method: :post, class: "btn btn-primary", confirm: t(:download_all_html, scope: "buttons") %>

In the end, My confirmation message shows the <br /> as is....

I believe I am following rails guidelines here, so any help would be appreciated to figure this one out.

Edit

I had already tried html_safe.

I have one other example that is working :

tags:
      error_message_html: "O número %{message} ou não existe ou já foi mapeado.<br />
      Por favor verifique que o número corresponde à empresa seleccionada "

and I invoke it inside a controller :

flash[:error] = t :error_message_html, scope: "forms.tags", message: params[:tag][:number]
MrWater
  • 1,797
  • 4
  • 20
  • 47

1 Answers1

1

Rails will escape the html contained in the translation

You can allow the html to be used with html_safe

<%= link_to (t :download_all, scope: "pages.home.customers").html_safe, user_download_all_path(user_id:current_user.id, is_retailer: params[:controller]=='suppliers' ? true : false), method: :post, class: "btn btn-primary", confirm: t(:download_all_html, scope: "buttons") %>
Intrepidd
  • 19,772
  • 6
  • 55
  • 63
  • Hi @Intrepidd, I actually had tried that before.. right now I added `<%= link_to (t :download_all, scope: "pages.home.customers").html_safe, user_download_all_path(user_id:current_user.id, is_retailer: params[:controller]=='retailers' ? true : false), method: :post, class: "btn btn-primary", confirm: (t :download_all_confirmation_html, scope: :buttons).html_safe`, but still keep getting the
    within my message... I'm running on a development windows machine, if that may influence somehow
    – MrWater Apr 21 '13 at 00:20