I have a multilingual website in Drupal 7. I have a view to display content and this view is in code in one of my custom module. I am not getting translation when view is in code and works fine when it's in database. Let me try to explain:
I added content field and rewrite the output of this field, wrapped with t() and excluded from display. I added another Global custom field and used replacement pattern to display that content field. I exported the view and saved it in code in one of custom module.
Now view is in code and everything is working fine as expected in default language (English). When I switched the language, it only show English for that content field and everything else showing translation.
I saved the view in Views UI without any change and now view is in database. I refreshed the page and I got the translation.
Any idea or help would be appreciated. Thanks!