ab-translate
Advanced tools
Comparing version 1.1.6 to 1.1.7
{ | ||
"private": false, | ||
"name": "ab-translate", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Yair Haimovitch", |
# ab-translate | ||
Quickly create ab tests for texts without coding via [Wix Babel](https://bo.wix.com/wix-babel-webapp/babel). | ||
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). | ||
# Installation - Yoshi | ||
1. Install the package `npm i ab-translate --save` | ||
2. Save the petri experiments object to the window (e.g. `window.__EXPERIMENTS__ = '<%= experiments %>';`) | ||
3. In the `src/i18n.js` file add the following code to the backend task | ||
The prcess requries two simple steps: | ||
1. [**Setup**](#setup) - one time config for a project to support the AB Translate flow | ||
2. [**Test**](#test) - create as many tests as you or you Product Manager wishes | ||
## Setup | ||
Do this once, for each project that you want to run translations tests in | ||
### Yoshi (new stack) | ||
1. Install the package `npm i ab-translate --save` or `yarn add ab-translate` | ||
2. Configure the specs defaults in your `package.json` file ([example](https://github.com/wix-private/account-recovery/blob/master/package.json#L15)): | ||
```javascript | ||
"yoshi": { | ||
"petriSpecs": { | ||
onlyForLoggedInUsers: false, // default: true | ||
scopes: ['my-projects-translation-scope'] // default: [<artifactId>] | ||
} | ||
} | ||
``` | ||
3. 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 | ||
4. In the `src/i18n.js` file add the following code to the backend task ([example](https://github.com/wix-private/account-recovery/blob/master/src/i18n/client-i18n.js#L22)) | ||
```javascript | ||
import abTranslate from ‘ab-translate/dist/src/abTranslate-runtime’; | ||
@@ -22,15 +38,31 @@ | ||
``` | ||
# Installation - Other Configurations | ||
### Wix Grunt (old stack) | ||
1. Install the package `npm i ab-translate --save` | ||
2. 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 | ||
<pre> | ||
import abTranslate from 'ab-translate'; | ||
. | ||
. | ||
. | ||
window.abTranslations = abTranslate(window.experiments, window.translations); | ||
strValue = window.abTranslations[strKey]; | ||
</pre> | ||
2. Configure the specs defaults in your local `Gruntfile.js` file: | ||
```javascript | ||
grunt.modifyTask('petriExperiments', { | ||
options: { | ||
onlyForLoggedInUsers: false, // default: true | ||
scopes: ['my-projects-translation-scope'] // default: [<artifactId>] | ||
} | ||
}); | ||
``` | ||
3. Add the Angular `abTranslateProvider` to your `index.vm` file ([example](https://github.com/wix-private/site-generator-statics-consumer/blob/00f9120d1964725aa3a89217f48978264210caa2/app/index.vm#L189)) | ||
```html | ||
<script src="bower_components/ab-translate.git/abTranslate.angular-runtime.bundle.min.js"></script> | ||
``` | ||
4. Transform the translations using the `abTranslateProvider` and the project's `experimentManagerProvider` ([example](https://github.com/wix-private/site-generator-statics-consumer/blob/15d0f98603a575b5eda742ede781cf63f791f04b/app/scripts/app.ts#L80)). *Notice:* make sure that you conduct the experiments for the scope in step #2 | ||
```javascript | ||
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); | ||
}); | ||
``` | ||
# Usage | ||
## Test |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3008484
68