I am trying to translate https://github.com/lifo/docrails/blob/master/activerecord/lib/active_record/associations.rb
In my controller file, I have:
@book = Book.find(params[:id]) begin @book.destroy rescue ActiveRecord::DeleteRestrictionError => e flash[:error]= e.message # <<< Translate this message ? end
This is the translation file I'm using: https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/th.rb
How to write code for translate "#{e.message}" ?
translate "#{e.message}"
You can use this in your en.yml file
en.yml
activerecord: book: error: 'book error: %{e}'
and u can block cheer salvage block with this
flash[:error] = t("book.error") % {:e => e.message}
it works in ma case
Source: https://habr.com/ru/post/1383875/More articles:Using the typedef name in the developed specifier - c ++How to update a graph or chart dynamically in android? - androidHow to kill a child process spawned by Java when tomcat is complete - javaXSL FO continued / tables, footers in the footer - xmlDelete / delete current image from ImageView? - androidASP.NET GridView joins two fields into one column - c #Windows Azure - frequent protocol violations with content length inconsistencies - asp.netHttpPostedFileBase to byte [] how to save the encoding? - c #How to use Oracle DMP files? - oracleEclipse error on startup: error notifying preference change listener - javaAll Articles