Importing all languages in node.js
See original GitHub issueThis is related to: https://github.com/PrismJS/prism/issues/593
The components are injected when you require the module, so can we have (for the node users) an index.js
inside components
folder, that does this?
require './prism-abap.js';
require './prism-actionscript.js';
require './prism-apacheconf.js';
// ...
So then we only have to use:
import prismjs from 'prismjs';
import 'prismjs/components';
Or even something like:
function loadComponents(arr) {
arr.foreach(function(language) {
require('./prism-' + language);
});
}
module.exports = loadComponents;
import prismjs from 'prismjs';
import loadComponents from 'prismjs/components';
loadComponents(['php', 'ruby']);
This won’t work in the browser i think, but why not have this simple helper for the node users?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Node.js Tutorial on Creating a Multilingual Web App | Phrase
We are going to place all the language files inside this folder. Each of the files is in the JSON format, and their...
Read more >Localization in Node.js and Express.js with i18n examples
Installing and configuring Node.js i18n and Node.js apps localization. How can your Express.js application support multiple languages.
Read more >How to import all exports of a file as an object in Node.js
Here, In the root folder of “GFG-MODULES”, there are 3 files namely “index.html”, “index.js” and our “package.json” file along with these, it ...
Read more >Languages with a NodeJS/CommonJS style module system
@svick Primarily the require function, which returns either a function or some other structured data. As opposed to 'import x from y' which ......
Read more >Loading locale in NodeJS
Docs · GitHub; Languages icon ... Loading locale in NodeJS. Loading locale on demand. require('dayjs/locale/de') // import 'dayjs/locale/de' // ES 2015 ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok, we added a
loadLanguages()
function that can be used as suggested here:It will load the required dependencies.
I still need to document this somewhere. I’ll close the issue once it’s done.
I found that if you don’t specify an array of languages, all of them will be loaded.
In TypeScript, I was able to load all languages using this syntax: