-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathconfig.json
More file actions
64 lines (64 loc) · 2.06 KB
/
Copy pathconfig.json
File metadata and controls
64 lines (64 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
"plugin_type": "widget",
"name": "Localized Copy Change",
"edit_page_url": "http://www.atticandbutton.us/",
"form_schema": [
{
"default_value": ".hero__title",
"field_type": "selector",
"name": "selector",
"label": "Element",
"options": null
},
{
"default_value": "New English Text",
"field_type": "text",
"name": "str_en",
"label": "English",
"options": null
},
{
"default_value": "New German Text",
"field_type": "text",
"name": "str_de",
"label": "German",
"options": null
},
{
"default_value": "New Spanish Text",
"field_type": "text",
"name": "str_es",
"label": "Spanish",
"options": null
},
{
"default_value": "str_de",
"field_type": "dropdown",
"name": "preview",
"label": "Preview Language",
"options": {
"choices": [
{
"value": "str_en",
"label": "English"
},
{
"value": "str_de",
"label": "German"
},
{
"value": "str_es",
"label": "Spanish"
}
]
}
}
],
"description": "Make a copy change on your website in multiple languages",
"options": {
"html": "",
"css": "",
"apply_js": "var utils = window.optimizely.get('utils');\nvar previewMode = (document.referrer.indexOf('app.optimizely.com') != -1 ? true : false);\n\nvar userLang = window.navigator.language || window.navigator.userLanguage;\nvar str;\n\nconsole.log(userLang);\n\nswitch (userLang) {\n\tcase 'en':\n\tcase 'en-US':\n\t\tstr = extension['str_en'];\n\t\tbreak;\n\t\t\n\tcase 'de':\n\t\tstr = extension['str_de'];\n\t\tbreak;\n\n\tcase 'es':\n\t\tstr = extension['str_es'];\n\t\tbreak;\n\n default: \n break;\n}\n\nif (previewMode === true) str = extension[extension.preview];\n\nutils.waitForElement(extension.selector).then(function() {\n\tif (str != undefined) document.querySelector(extension.selector).innerText = str;\n});\n\n\n",
"undo_js": ""
}
}