I was trying to learn this tutorial with JiT and angular-cli. I have got the following errors in browser console but no error in terminal to run/build the app.
Uncaught ReferenceError: System is not defined(…)
Uncaught Error: Cannot find module './locale/messages.fr.xlf!text'.(…)
My code in github https://github.com/sayedrakib/internationalization_project.git
I have added systemjs-text-plugin.js in the root folder, according to instruction in the tutorial. File structure
I think I have messed up with file path in some files, because I felt the assumed file structure in tutorial and angular-cli created file structure is not same.
I can see you are using angular-cli, than if you want to load 3party libery you need to work with angular-cli.json file.
First run at your app directory npm install systemjs
Second you need to add the path of systemjs at your angular-cli.json file.
"scripts": [
"../node_modules/systemjs/dist/system.js"
]
if you need to load other 3party libery just repeat the 2 stages.
Took me ages to figure this out!
If you followed the documentation, change this:
Finally it looks like this:
index.html
<body>
<app-root>Loading...</app-root>
<script src="system.js"></script>
<script>
// Get the locale id somehow
document.locale = 'es';
// Map to the text plugin
SystemJS.config({
map: {
text: 'systemjs-text-plugin.js'
}
});
</script>
</body>
i18n-providers.ts
export function getTranslationProviders(): Promise<Object[]> {
[...]
}
declare let SystemJS: any;
function getTranslationsWithSystemJs(file: string) {
return SystemJS.import(file + '!text'); // relies on text plugin
}
I opened a GitHub Issue to update documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With