ab-translate-old
v1.1.0
Published
Quickly create AB Tests for texts without coding via [Wix Babel](https://bo.wix.com/wix-babel-webapp/babel) & [Guineapig](https://guineapig.wix.com/home).
Downloads
3
Maintainers
Keywords
Readme
ab-translate
Quickly create AB Tests for texts without coding via Wix Babel & Guineapig.
The process requries two simple steps:
- Setup - one time config for a project to support the AB Translate flow
- AB Test - create as many text tests as you or your Writer needs without writing a single line of code!!!!1 😱
Setup
Do this once, for each project that you want to run translations tests in
Yoshi (new stack)
- Install the package
npm i ab-translate --save
oryarn add ab-translate
- Configure the specs defaults in your
package.json
file (example):
"yoshi": {
"petriSpecs": {
onlyForLoggedInUsers: false, // default: true
scopes: ['my-projects-translation-scope'] // default: [<artifactId>]
}
}
- Save the petri experiments object to the window (e.g.
window.__EXPERIMENTS__ = '<%= experiments %>';
). Notice: make sure that you conduct the experiments for the scope in step #2 - In the
src/i18n.js
file add the following code to the backend task (example)
import abTranslate from ‘ab-translate/dist/src/abTranslate-runtime’;
backend: {
crossDomain: true,
parse: translations => {
try {
return abTranslate(window.__EXPERIMENTS__, JSON.parse(translations));
} catch (e) {
return translations;
}
}
}
Wix Grunt (old stack)
- Install the package
npm i ab-translate --save
- Configure the specs defaults in your local
Gruntfile.js
file:
grunt.modifyTask('petriExperiments', {
options: {
onlyForLoggedInUsers: false, // default: true
scopes: ['my-projects-translation-scope'] // default: [<artifactId>]
}
});
- Add the Angular
abTranslateProvider
to yourindex.vm
file (example)
<script src="bower_components/ab-translate.git/abTranslate.angular-runtime.bundle.min.js"></script>
- Transform the translations using the
abTranslateProvider
and the project'sexperimentManagerProvider
(example). Notice: make sure that you conduct the experiments for the scope in step #2
angular.module('myApp', [])
.config(function($translateProvider, abTranslateProvider, experimentManagerProvider) {
const preferredLanguage = $translateProvider.preferredLanguage();
const translations = $translateProvider.translations()[preferredLanguage];
const translationsWithExperiments = abTranslateProvider.abTranslate.default(
experimentManagerProvider.experiments,
translations
);
$translateProvider.translations(preferredLanguage, translationsWithExperiments);
});
AB Test
- Go to the Babel translation system
- Select your project in the
Current Project
dropdown and select theUpdate
tab - Look for the translation key you want to create a test for and click on the
Edit
button - Click on the
Create AB Test
button at the bottom of the modal - Add as many alternatives as you want
- Click the
Set
button. A 🔀 sign should appear next to your key. - Verify your changes and click the
Commit
button. - The changes will be pushed to github and a new build will be triggered. The new AB test will be detected and will be created.
- In the Next GA of the project you'll be able to see the spec in Guineapig. The spec name will be in the format
specs.abTranslate.<scope>.<key>
. - Create an experiment and use Petri Sidekick to verify the variations!
Note1: When creating the experiment verify that you open it only for the languages where the keys were updated Note2: If the experiment is paused/killed/theres a bug in the system the first alternative (String #0) will be chosen so there shouldn't be any risks with this mechanism.
Merging an Experiment
Unfurtunately, at the moment there's no Quick Merge
button that allows you to select the winning text. We'll work on one once the demand will rise. In the mean time you can simply set all the alternatives to the same text, close the experiments, and finally ask your dev to remove the unnecessary keys.
Experiments in languages other than EN
Creating an experiment in other languages is possible, however there's a few things you should keep in mind:
- Make sure that all variations are translated otherwise you'll have some variations fallback to English
- When you merge a multi-lingual experiment the winner for each language might be different (in some languages A may win, while in other languages B, or C, etc). Keep that in mind when you get to that point. We hope to make your life easier with an auto-merge flow in the future :)
Credits
- Guild Week Stars ✨
- FED Infra Team