-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable ckeditor5 builds to work with RequireJS #385
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
da0ae41
Updated serveTranslations and MultipleLanguageTranslationService.
ma2ciek f7650d9
Fixed tests.
ma2ciek e6dc33d
Removed unnecesary end line.
ma2ciek 3f8d463
Changed function to arrow function.
ma2ciek 5893351
Improved asset concatenation.
ma2ciek 49302db
Merge branch 'master' into t/ckeditor5/914
Reinmar 610fc8a
Merge branch 'master' into t/ckeditor5/914
Reinmar d80d161
Use ES5.
Reinmar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,13 +176,13 @@ module.exports = class MultipleLanguageTranslationService extends EventEmitter { | |
} | ||
|
||
const mainAssetName = compilationAssetNames[ 0 ]; | ||
const mainCompilationAsset = compilationAssets[ mainAssetName ]; | ||
|
||
const mainTranslationAsset = this._getTranslationAssets( outputDirectory, [ this._mainLanguage ] )[ 0 ]; | ||
|
||
const mergedCompilationAsset = { | ||
outputBody: mainCompilationAsset.source() + '\n;' + mainTranslationAsset.outputBody, | ||
outputPath: mainAssetName | ||
outputBody: mainTranslationAsset.outputBody, | ||
outputPath: mainAssetName, | ||
shouldConcat: true | ||
}; | ||
|
||
const otherLanguages = Array.from( this._languages ) | ||
|
@@ -211,7 +211,16 @@ module.exports = class MultipleLanguageTranslationService extends EventEmitter { | |
const stringifiedTranslations = JSON.stringify( translatedStrings ) | ||
.replace( /"([a-z]+)":/g, '$1:' ); | ||
|
||
const outputBody = `CKEDITOR_TRANSLATIONS.add('${ language }',${ stringifiedTranslations })`; | ||
const outputBody = ( | ||
// We need to ensure that the CKEDITOR_TRANSLATIONS variable exists and if it exists, we need to extend it. | ||
// Use ES5 because this bit will not be transpiled! | ||
'(function(d){' + | ||
`d['${ language }']=Object.assign(` + | ||
`d['${ language }']||{},` + | ||
`${ stringifiedTranslations }` + | ||
')' + | ||
'})(window.CKEDITOR_TRANSLATIONS||(window.CKEDITOR_TRANSLATIONS={}));' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that this kind of access to the global object (through |
||
); | ||
|
||
return { outputBody, outputPath }; | ||
} ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still an ES6 code. We can change it to
for in
loop to be fully ES5 compatible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object.assign()
needs to be provided by a polyfill for the rest of the code anyway. This doesn't get transpiled.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be tricky for someone, as we add that code at the top of the bundle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now we don't support any non-ES6 env anyway, so it's even hard to test. Let's keep it in our minds. But I don't see a problem in injecting the ES6 polyfill before our scripts.