0
votes

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!

1

1 Answers

0
votes

Try writing an update script that saves your view that's in code into the database with $view->save();

When you update the view, you will always need an update script that updates the view in the database:

$view->delete();
ctools_include('object-cache');
ctools_object_cache_clear('view', $view->name);
$view->save();