Created
September 23, 2020 19:20
-
-
Save davist11/d0630e8e91c8ffa5fd6ebdafd835236b to your computer and use it in GitHub Desktop.
Redactor Language Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($R) { | |
$R.add("plugin", "language", { | |
translations: { | |
en: { | |
language: "Change Language", | |
}, | |
}, | |
init: function (app) { | |
this.app = app; | |
this.opts = app.opts; | |
this.lang = app.lang; | |
this.block = app.block; | |
this.toolbar = app.toolbar; | |
this.options = this.opts.languages; | |
this.currentLangAttr; | |
}, | |
start: function () { | |
var dropdown = {}; | |
for (var key in this.options) { | |
var value = this.options[key]; | |
dropdown[key] = { | |
title: value, | |
api: "plugin.language.set", | |
args: key, | |
}; | |
} | |
var $button = this.toolbar.addButton("language", { | |
title: this.lang.get("language"), | |
}); | |
$button.setIcon('<i class="re-icon-specialcharacters"></i>'); | |
$button.setDropdown(dropdown); | |
}, | |
set: function (lang) { | |
if (!this.currentLangAttr) { | |
this.addAttribute(lang); | |
this.currentLangAttr = lang; | |
} else if (this.currentLangAttr === lang) { | |
this.removeAttribute(); | |
this.currentLangAttr = null; | |
} else { | |
this.removeAttribute(); | |
this.addAttribute(lang); | |
this.currentLangAttr = lang; | |
} | |
}, | |
addAttribute: function (lang) { | |
var args = { | |
attr: { | |
lang: lang, | |
}, | |
}; | |
this.block.set(args); | |
}, | |
removeAttribute: function () { | |
var args = { | |
attr: { | |
lang: this.currentLangAttr, | |
}, | |
}; | |
this.block.toggle(args); | |
}, | |
}); | |
})(Redactor); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"buttons": [ | |
"html", | |
"formatting", | |
"bold", | |
"italic", | |
"unorderedlist", | |
"orderedlist", | |
"link", | |
"image", | |
"video" | |
], | |
"plugins": [ | |
"fullscreen", | |
"video", | |
"language" | |
], | |
"toolbarFixed": true, | |
"languages": { | |
"en-US": "English (US)", | |
"en-GB": "English (GB)" | |
} | |
} |
The font awesome CSS is not included
If that were possible, I think the globe would be the most logical fit. If not, the Omega from your screenshot in Slack works fine enough.
How could I test this out? Maybe on Viget.com staging?
As you know, urgency on this is very low, so no need to respond right away.
How could I test this out?
Spinning up a craft site locally and adding the plugin is likely the easiest method for testing. Not really a whole lot to test though...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The redactor docs make it seem like fontawesome support is built in, is that true? https://fontawesome.com/v4.7.0/icon/language could be a good fit for the icon.