Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Fixed legacy translations not working.
Browse files Browse the repository at this point in the history
  • Loading branch information
phaux committed Feb 13, 2020
1 parent 4b49152 commit 09545d2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/translation-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,24 @@ function getMessage( language, msgCtx, msgId ) {
const localeData = window.CKEDITOR_TRANSLATIONS[ language ];
if ( localeData != null ) {
let key = String( msgId ).toLowerCase();
if ( msgCtx !== null ) {
if ( msgCtx != null ) {
key = `${ String( msgCtx ).toLowerCase() }|${ key }`;
}

const message = localeData[ key ];
if ( message != null ) {
return message;
}

// Fall back to the old behavior where context was not used
if ( msgCtx == null ) {
for ( const localeKey in localeData ) {
const localeKeyMatch = localeKey.match( /^(.+)\|(.+)$/ );
if ( localeKeyMatch != null && localeKeyMatch[ 2 ] == key ) {
return localeData[ localeKey ];
}
}
}
}

return null;
Expand Down

0 comments on commit 09545d2

Please sign in to comment.