简体   繁体   中英

In Rails, how to translate buttons in javascript popup confirm box

When including data: { confirm: "Are you sure?" } data: { confirm: "Are you sure?" } to a link_to helper, how do we translate the two buttons "Cancel" and "OK" in the popup?

Is the Rail's I18n applicable in some way?

By default (relying on the data-confirm attribute and calling window.confirm() ), rails-ujs uses the browser's native confirmation dialogs, so you can't really translate them, they will use the browser's translation.

If you use some alternative solution (which actually replaces the data-confirm attribute with something else) the views depend on the specific solution you choose (for example http://lesseverything.com/blog/archives/2012/07/18/customizing-confirmation-dialog-in-rails/ )

TL;DR: You can't.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM