ab-translate
Quickly create ab tests for texts without coding via Wix Babel.
Installation - Yoshi
- Install the package
npm i ab-translate --save
- Save the petri experiments object to the window (e.g.
window.__EXPERIMENTS__ = '<%= experiments %>';
) - In the
src/i18n.js
file add the following code to the backend task
import abTranslate from 'ab-translate';
.
.
.
backend: {
crossDomain: true,
parse: function(translations) {
try {
return = abTranslate(JSON.parse(window.__EXPERIMENTS__), JSON.parse(translations));
} catch (e) {
return translations;
}
}
}
Installation - Other Configurations
- Install the package
npm i ab-translate --save
- In a location where both the experiments and the translations json are available, use the abTranslate function to convert the regular translations json to a modified one that includes the experiments results
import abTranslate from 'ab-translate';
.
.
.
window.abTranslations = abTranslate(window.experiments, window.translations);
strValue = window.abTranslations[strKey];
Usage