TinyMCE translation

TinyMCE translation

In some versions, TinyMCE refuses to use the Users preferred language. This can be a timing issue. But there might also be some (SilverStripe) language files missing for the selected profile language!

Profile language in 2.4

Changing the language for a user profile fails in the TinyMCE editor.

Reason

The default editor properties are set in the cms/_config.php file. To get the language for the editor, the i18n::get_tinymce_lang() is called, that in it's turn calls i18n::get_locale() to obtain the $current_locale. This value is set from the LeftAndMain class' init() method, which at that moment unfortunately hasn't happened yet.

Solution

Adding  the call to i18n::get_tinymce_lang() to the end of mysite/_config.php will create a long enough delay for it to work:

// Set the editor language: calling this from the cms/_config.php 
// may fail, because $current_language is not set yet
HtmlEditorConfig::get('cms')->setOptions(array(
	'language' => i18n::get_tinymce_lang(),
));

SilverStripe ssbuttons

A couple of button tooltips, like for instance 'Insert Image' will not be properly translated. You'll see something like {#tinymce_ssbuttons.insertimage}.

Reason

The proper languagefile in cms/javascript/tinymce_ssbuttons/langs/ is missing.

Solution

Copy the en.js to the language of choice, and adapt. For the Dutch language this would be:

cms/javascript/tinymce_ssbuttons/langs/nl.js:

tinyMCE.addI18n('nl.tinymce_ssbuttons', {
	insertlink: 'Link invoegen',
	insertimage: 'Afbeelding invoegen',
	insertflash: 'Flash Object invoegen'
});

HTML Source editor

The same thing occurs in the HTML popup, where you'll see something likeIn this case you need to create/adapt the following files. Again, for the Dutch language:

sapphire/thirdpartytinymce_advcode/langs/nl.js

tinyMCE.addI18n('nl.advcode',{
	desc : 'HTML broncode bewerken'
})

sapphire/thirdpartytinymce_advcode/langs/nl_dlg.js

tinyMCE.addI18n('nl.advcode_dlg',{
	title : 'HTML Broncode Editor',
	number_toggle : 'Regelnummers tonen'
})

Comments

Het versturen van reacties is uitgeschakeld.

RSS feed voor reacties op deze pagina