Issue #2674💬 AnsweredOpened March 20, 2020by teawithfruit1 reactions

I18n content integration

Quick answerby artf1

@teawithfruit if you expect something in your saved HTML page (outside of the GrapesJS editor) the only thing I see it can do is: So it does nothing, probably you're another victim of thinking that scripts inside GrapesJS editor will work in the exported code (but the final HTML has nothing to do with the editor). A b...

Read full answer below ↓

Question

Hello, I'm working on an integration of my localization system (i18n) with grapes.js. The idea is to have a data field, which will hold the i18n string. If the data attribute is set, grapes.js will take the string and make it visible in a settings field. If the settings field is altered, the data attribute is also altered and also the content inside the canvas. If the settings field is cleared, the data attribute will be deleted. If the file is saved, the attributes will be included. When using the file in production, a little script is searching for the data-i18n attribute to set the text in...

Answers (3)

artfApril 1, 2020

@teawithfruit if you expect something in your saved HTML page (outside of the GrapesJS editor) the only thing I see it can do is: So it does nothing, probably you're another victim of thinking that scripts inside GrapesJS editor will work in the exported code (but the final HTML has nothing to do w...

pouyamiralayiMarch 21, 2020

Hi @teawithfruit there are a couple of issues with your code: 1) you don't have access to `this as the model inside component script`: Component & Js docs 2) if your use case is to control an attribute, you don't have to provide a custom trait for that; just define a regular trait, and add listener...

teawithfruitMarch 23, 2020

Thank you for the very helpful the answer! This is my updated Block/Component. Right now I've got just one more problem. The script function I've added to the component is not called in the saved html page. If I add the block to the canvas in the editor, the function is called, but not if I save th...

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.