Skip to content

Commit

Permalink
Translation for link dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
gotcha committed Dec 21, 2023
1 parent 689b840 commit 2766bd8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/collective/ckeditor/browser/ckeditorview.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def getCK_plone_config(self):
config.%s = %s;
""" % (k, v)

ids = []
ids = ['plone']
for line in get_registry_value('plugins', []):
# ignore the rest so we get no error
if len(line.split(';')) == 2:
Expand Down
34 changes: 29 additions & 5 deletions src/collective/ckeditor/browser/statics/ckeditor_plone.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,14 @@ jQuery(document).on('after-render.plone-modal.patterns', launchCKInstances);
(function() {

var format = function format(msg) {
return '<p>Actual URL</p><p>'+msg+'</p>';
var ploneLang = editor.lang.plone;
return '<p>'+ploneLang.actual_url+'</p><p>'+msg+'</p>';
};

var showActualUrl = function showActualUrl(domElement, url) {
var ploneLang = editor.lang.plone;
if (url.indexOf('resolveuid') !== -1) {
domElement.setHtml(format('Loading...'));
domElement.setHtml(format(ploneLang.loading));
var current_uid = url.split('resolveuid/')[1];
var new_url = CKEDITOR_PLONE_PORTALPATH + '/convert_uid_to_url/' + current_uid;
var settings = {
Expand All @@ -128,11 +130,11 @@ jQuery(document).on('after-render.plone-modal.patterns', launchCKInstances);
if (jqXHR.status == 200) {
domElement.setHtml(format(data));
} else {
domElement.setHtml(format('Could not be resolved.'));
domElement.setHtml(format(ploneLang.could_not_be_resolved));
}
},
error: function(jqXHR, textStatus){
domElement.setHtml(format('Could not be resolved.'));
domElement.setHtml(format(ploneLang.could_not_be_resolved));
}
};
$.ajax(settings);
Expand All @@ -141,6 +143,27 @@ jQuery(document).on('after-render.plone-modal.patterns', launchCKInstances);
domElement.setHtml('<p></p>');
};

CKEDITOR.plugins.add('plone', {name: 'plone', path: 'plone'});
CKEDITOR.plugins.setLang('plone', 'en', {
invalid_ruid_protocol: 'When using internal link that contains "resolveuid", the value of the "Protocol" field needs to be "<other>".',
actual_url: 'Actual URL',
loading: 'Loading...',
could_not_be_resolved: 'Could not be resolved.',
});
CKEDITOR.plugins.setLang('plone', 'fr', {
invalid_ruid_protocol: 'Quand vous utilisez un lien interne qui contient "resolveuid", la valeur du champs "Protocole" doit être "<autre>".',
actual_url: 'URL finale',
loading: 'En cours...',
could_not_be_resolved: "Ne peut être déterminée.",
});
CKEDITOR.plugins.setLang('plone', 'nl', {
invalid_ruid_protocol: 'Als je een interne link met "resolveuid" erin gebruikt, moet het "Protocol" veld "<ander>" zijn.',
actual_url: 'Feitelijke URL',
loading: 'Laden...',
could_not_be_resolved: "Kan niet berekend worden.",
});


CKEDITOR.on( 'dialogDefinition', function( ev ) {
// Take the dialog name and its definition from the event
// data.
Expand Down Expand Up @@ -180,12 +203,13 @@ CKEDITOR.on( 'dialogDefinition', function( ev ) {

var default_validate = url.validate;
url.validate = function() {
var ploneLang = editor.lang.plone;
if ( this.getValue().includes('resolveuid') ) {
var dialog = this.getDialog();
var protocol = dialog.getValueOf('info', 'protocol');
console.log("protocol: " + protocol);
if ( protocol != '') {
alert( 'When using internal link that contains resolveuid, protocol needs to be <other>.' );
alert( ploneLang.invalid_ruid_protocol );
return false;
}
}
Expand Down

0 comments on commit 2766bd8

Please sign in to comment.