Problem/Motivation

Under normal operation, the smartling_translation_context submodule hooks css_alter in order to convert attached stylesheets into embedded style elements within the uploaded context document. When the LESS CSS Preprocessor module is also in use, the CSS array passed to the alter function may contain references to .less files which will be replaced in a later step just prior to page rendering. These references are ignored by the smartling module, and on a site where CSS aggregation is enabled, the resulting page will contain a mix of smartling-processed CSS and <link> elements generated by the LESS module processing phase. Those
elements are then stripped out by the htmlSaveComplete utility class of the smartling context module, which can result in the bulk of the theme styles not being present at all in the uploaded context. Needless to say this can severely degrade or eliminate the usefulness of the context.

Proposed resolution

As a general workaround, we propose a slight modification (see attached patch) to the offending class so that it preserves link elements which reference stylesheets. This should increase the likelihood that the uploaded context will display properly for certain sites where CSS processing may be subject to influences outside of the normal mechanism.

Comments

gwheelerky created an issue. See original summary.

gwheelerky’s picture

loparev’s picture

StatusFileSize
new51.76 KB
new34.45 KB

Hi, @gwheelerky

Thank you for the patch attached. But I would suggest a bit another approach. Recently we've moved to Smartling Context APIv2 and now we don't have to inline images/css files on connector side. We only should upload missing resources in case context API couldn't download it by itself. So in this patch we've got rid of all the code which embeds css/images into html context file and we've implemented resources uploading.

Could you please try this patch (smartling-2924497-3-full.patch) and confirm that it works for you? I mean try two cases: manual context uploading and uploads by cron.

loparev’s picture

StatusFileSize
new51.78 KB
new401 bytes

  • Loparev committed 656ea9e on 7.x-3.x
    Issue #2924497 by Loparev, gwheelerky: Add fallback logic to ensure that...
loparev’s picture

I've committed these changes. From now we don't do any inlining on connector side. This must work for your case with LESS module.

Please let me know if you have questions or you still experience the issue.

cobadger’s picture

Status: Needs review » Reviewed & tested by the community

@loparev I tested 7.x-3.4 which includes your commit of smartling-2924497-4.patch in our project that uses the LESS engine and it works as intended, both with cron-based context uploading (via the popup window) and manual context uploading at admin/content/smartling-content/node.

Changing status to RTBC.

loparev’s picture

Thank you, @COBadger

loparev’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.