Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Core overhauled. 100% tested. API simplified. Removed JSON layer. Memory cache only reindex on syncing. Improved storages. Added more examples.
- Loading branch information
Showing
16 changed files
with
617 additions
and
1,024 deletions.
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
var dialect = require('..').dialect({ | ||
locales: ['es', 'en'], | ||
current_locale: 'es', | ||
store: {mongodb: {}} // test your store here | ||
}), | ||
funk = require('funk')(), | ||
funk2 = require('funk')(), | ||
times = 300, | ||
_ = dialect.get, | ||
original = 'Hello World!', | ||
translation = 'Hola Mundo!'; | ||
|
||
dialect.connect(function () { | ||
var i = 0, | ||
now = Date.now(), | ||
time = null; | ||
|
||
console.log('Setting ' + times + ' translations...'); | ||
|
||
for (i = 0; i < times; i ++) { | ||
_(original); | ||
dialect.set({original: original, locale: 'es'}, translation, funk.nothing()); | ||
|
||
//dialect.sync({}, function (err, foo) { | ||
//_(original); | ||
//_('Inexistant'); | ||
//}); | ||
} | ||
|
||
funk.parallel(function () { | ||
time = Date.now() - now; | ||
console.log(time + 'ms'); | ||
console.log(parseInt(1000 / ( time / times)) + ' sets/sec'); | ||
}); | ||
|
||
dialect.sync({}, function (err, foo) { | ||
now = Date.now(); | ||
time = null; | ||
|
||
console.log('Getting ' + times + ' translations...'); | ||
for (i = 0; i < times; i ++) { | ||
_(original); | ||
} | ||
time = Date.now() - now; | ||
console.log(time + 'ms'); | ||
console.log(parseInt(1000 / (time / times)) + ' gets/sec'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var dialect = require('..').dialect({ | ||
locales: ['es', 'en'], | ||
current_locale: 'es', | ||
store: {mongodb: {}} | ||
}), | ||
_ = dialect.get; | ||
|
||
dialect.connect(function () { | ||
console.log(_(['Fight', {context: 'name'}])); | ||
console.log(_(['Fight', {context: 'verb'}])); | ||
|
||
dialect.set({original: 'Fight', locale: 'es', context: 'name'}, 'Lucha'); | ||
dialect.set({original: 'Fight', locale: 'es', context: 'verb'}, 'Luchar'); | ||
|
||
dialect.sync({interval: 3600}, function (err, foo) { | ||
console.log(_(['Fight', {context: 'name'}])); | ||
console.log(_(['Fight', {context: 'verb'}])); | ||
process.exit(); | ||
}); | ||
}); |
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
Oops, something went wrong.