Skip to content

Commit

Permalink
Use Django language code to configure language for TinyMCE.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenmcd committed May 23, 2015
1 parent 82866e1 commit 2130cfd
Showing 1 changed file with 95 additions and 2 deletions.
97 changes: 95 additions & 2 deletions mezzanine/core/static/mezzanine/js/tinymce_setup.js
@@ -1,4 +1,97 @@

// Map Django language codes to valid TinyMCE language codes.
// There's an entry for every TinyMCE language that exists,
// so if a Django language code isn't here, we can default to en.
// Rather than assuming the language codes map perfectly between
// Django and TinyMCE, we map them here so that they can be
// tweaked - they've not yet all been verified to be correct.

var language_codes = {
'ar': 'ar',
'az': 'az',
'be': 'be',
'bg': 'bg',
'bn': 'bn',
'br': 'br',
'bs': 'bs',
'ca': 'ca',
'ch': 'ch',
'cn': 'cn',
'cs': 'cs',
'ct': 'ct',
'cy': 'cy',
'da': 'da',
'de': 'de',
'dv': 'dv',
'el': 'el',
'en': 'en',
'eo': 'eo',
'es': 'es',
'et': 'et',
'eu': 'eu',
'fa': 'fa',
'fi': 'fi',
'fr': 'fr',
'gl': 'gl',
'gu': 'gu',
'he': 'he',
'hi': 'hi',
'hr': 'hr',
'hu': 'hu',
'hy': 'hy',
'ia': 'ia',
'id': 'id',
'is': 'is',
'it': 'it',
'ja': 'ja',
'ka': 'ka',
'kb': 'kb',
'kk': 'kk',
'kl': 'kl',
'km': 'km',
'ko': 'ko',
'lb': 'lb',
'lt': 'lt',
'lv': 'lv',
'mk': 'mk',
'ml': 'ml',
'mn': 'mn',
'ms': 'ms',
'my': 'my',
'nb': 'nb',
'nl': 'nl',
'nn': 'nn',
'no': 'no',
'pl': 'pl',
'ps': 'ps',
'pt': 'pt',
'ro': 'ro',
'ru': 'ru',
'sc': 'sc',
'se': 'se',
'si': 'si',
'sk': 'sk',
'sl': 'sl',
'sq': 'sq',
'sr': 'sr',
'sv': 'sv',
'sy': 'sy',
'ta': 'ta',
'te': 'te',
'th': 'th',
'tn': 'tn',
'tr': 'tr',
'tt': 'tt',
'tw': 'tw',
'uk': 'uk',
'ur': 'ur',
'vi': 'vi',
'zh-cn': 'zh-cn',
'zh-tw': 'zh-tw',
'zh': 'zh',
'zu': 'zu'
};

function CustomFileBrowser(field_name, url, type, win) {
tinyMCE.activeEditor.windowManager.open({
file: window.__filebrowser_url + '?pop=2&type=' + type,
Expand Down Expand Up @@ -26,7 +119,7 @@ jQuery(function($) {
mode : "specific_textareas",
editor_selector : "mceEditor",
theme: "advanced",
language: "en",
language: language_codes[window.__language_code] || 'en',
dialog_type: "window",
editor_deselector : "mceNoEditor",
skin: "thebigreason",
Expand All @@ -46,7 +139,7 @@ jQuery(function($) {
external_link_list_url: '/displayable_links.js',
relative_urls: false,
convert_urls: false,

// enable browser's built in spell checking
gecko_spellcheck: true,

Expand Down

0 comments on commit 2130cfd

Please sign in to comment.