Skip to content

Commit e096626

Browse files
committed
Merge branch 't/9688b'
2 parents 4f213b5 + 21fb447 commit e096626

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

core/editor.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,21 @@
448448
pluginLangs = pluginLangs.split( ',' );
449449

450450
// Resolve the plugin language. If the current language
451-
// is not available, get the first one (default one).
452-
lang = ( CKEDITOR.tools.indexOf( pluginLangs, editor.langCode ) >= 0 ? editor.langCode : pluginLangs[ 0 ] );
451+
// is not available, get English or the first one.
452+
if ( CKEDITOR.tools.indexOf( pluginLangs, editor.langCode ) >= 0 )
453+
lang = editor.langCode;
454+
else {
455+
// The language code may have the locale information (zh-cn).
456+
// Fall back to locale-less in that case (zh).
457+
var langPart = editor.langCode.replace( /-.*/, '' );
458+
if ( langPart != editor.langCode && CKEDITOR.tools.indexOf( pluginLangs, langPart ) >= 0 )
459+
lang = langPart;
460+
// Try the only "generic" option we have: English.
461+
else if ( CKEDITOR.tools.indexOf( pluginLangs, 'en' ) >= 0 )
462+
lang = 'en';
463+
else
464+
lang = pluginLangs[ 0 ];
465+
}
453466

454467
if ( !plugin.langEntries || !plugin.langEntries[ lang ] ) {
455468
// Put the language file URL into the list of files to

plugins/a11yhelp/plugin.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
editor.addCommand( commandName, {
2424
exec: function() {
2525
var langCode = editor.langCode;
26-
langCode = plugin.availableLangs[ langCode ] ? langCode : 'en';
26+
langCode =
27+
plugin.availableLangs[ langCode ] ? langCode :
28+
plugin.availableLangs[ langCode.replace( /-.*/, '' ) ] ? langCode.replace( /-.*/, '' ) :
29+
'en';
2730

2831
CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( plugin.path + 'dialogs/lang/' + langCode + '.js' ), function() {
2932
editor.lang.a11yhelp = plugin.langEntries[ langCode ];

plugins/specialchar/plugin.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ CKEDITOR.plugins.add( 'specialchar', {
2323
editor.addCommand( pluginName, {
2424
exec: function() {
2525
var langCode = editor.langCode;
26-
langCode = plugin.availableLangs[ langCode ] ? langCode : 'en';
26+
langCode =
27+
plugin.availableLangs[ langCode ] ? langCode :
28+
plugin.availableLangs[ langCode.replace( /-.*/, '' ) ] ? langCode.replace( /-.*/, '' ) :
29+
'en';
2730

2831
CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( plugin.path + 'dialogs/lang/' + langCode + '.js' ), function() {
2932
CKEDITOR.tools.extend( editor.lang.specialchar, plugin.langEntries[ langCode ] );

0 commit comments

Comments
 (0)