-
Notifications
You must be signed in to change notification settings - Fork 39
Conversation
This is a great start, @lukaszewczak!
|
Hey @lukaszewczak, sorry to leave you hanging. I'm finding a little time to dig into this now. Rather than the exported module being giant JSON file(s) that are too big to fit in memory, I think we should explore exporting a leveldb instance. Upsides:
Downsides:
How it could work: leveldb is a simple key-value data store, and I think keys can actually be objects. Every file is identifiable by three unique properties: node version, language, and filename. We could store entries using a key like this: const key = {
nodeVersion: 'v10.x',
language: 'en-US',
filename: 'doc/api/path.md'
} If one wanted to fetch a specific record: const i18n = require('nodejs/i18n')
const key = {
nodeVersion: 'v10.x',
language: 'en-US',
filename: 'doc/api/path.md'
}
const file = await i18n.get(key) And if one wanted to operate on all the records in a specific language and/or version: const i18n = require('nodejs/i18n')
i18n.createReadStream()
.on('data', ({key, value}) => {
const {nodeVersion, language, filename} = key
if (nodeVersion === 'v8.x' && language === 'en-US') {
console.log(value)
}
})
.on('end', () => {
console.log('done')
}) cc level-wiz @juliangruber 🎩 🐇 -- Does this make sense? Am I right about the keys? Is this a good idea? A bad idea? |
In related news, I noticed that @rubys is working on nodejs/node#21490, an effort to replace |
I pushed up a new branch called level-module based on this branch. Noteworthy changes are here: Lines 16 to 24 in c9ecda0
|
Hi @zeke, Thank you for your work, which is great and definnetly a better approch. I'm sorry but I'm currently on holiday, this is why I wasn't active and I can back to this subject after July 28. Should I close this PR if you prepared branch based on I have one concern about this module specific to the usage of this module. If the new node.js website will have a dependency on this module, how often maintainers of the project will want to update dependency to have a new version of translations. I'm thinking about using some cloud for store... |
For Electron's website we have a process that runs on Heroku every ten minutes to update trusted dependencies: https://github.com/electron/electronjs.org/blob/a6ea42d6b66afff0ebbd695d13f145f5cc2666c0/script/update-deps.sh#L18-L27 |
Hi @zeke , I saw the discussion about that module on nodejs/website-redesign#76 (comment), its great that it can be used, can I help you somehow, with this npm module? Should I close this PR? |
@lukaszewczak this is pretty out of date so I'm going to close this out. Let's move further discussion to #261 |
Hi all,
After some break, I slowly start to work on #92 to create
nodejs-i18
module, based onelectron-i18 module
. I set up this PR asWIP
because I stuck on one problem, where maybe we all will be able to discuss it for some good ideas.So I start to prepare script based on electron-module, but I want to build Object with locales grouped by node.js version, but for me It was the first time, when my node.js process was gone with error
Allocation failed - JavaScript heap out of memory
, so I think it will be good to create separate json file for specific node.js version with one mainindex.js
module which exports function with parameter node.js version, which will return specific json file, but I had problem with saving this big javascript object to file, it should be probably done with streams, but I do not know how to write JS object with streams to file 😞, even if I will be able to prepare this file , it could be difficult to consume it by another project because of the json file size.@zeke had suggestion to use
leveldb
, I think this can be a good direction to use some store like this one.Here is a current sample of created json file, only for node.js version 10 and `en-US` locale, without parsed markdown files.