I'm currently doing this in a controller:
def index
@orders = Order.all
respond_to do |format| {
format.html
format.js { render json: @orders.as_json()
}
end
I have a order state field. The values of this field are in English and need to be translated to Dutch. Problem is, the as_json call doesn't automatically translate the data to Dutch. The YML file and current and default locale all are working correctly. ( calling I18n.t works, but how does this work with as_json() ? )
Thanks!
You can override as_json in your model and call i18n from that method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With