Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added feature to turn off automatic locale file updating.

  • Loading branch information...
commit 1eb5ca358121143308e796c30365208547238aeb 1 parent d773772
@msporny msporny authored
Showing with 21 additions and 2 deletions.
  1. +10 −2 README.md
  2. +11 −0 i18n.js
View
12 README.md
@@ -164,7 +164,15 @@ that file can be edited or just uploaded to [webtranslateit](http://docs.webtran
},
"tree": "Baum"
}
-
+
+to turn off automatic locale file updates:
+
+ // turn off locale file updating in production mode
+ i18n.configure({
+ // disable locale file updates
+ updateFiles: false
+ });
+
## Changelog
* 0.3.5: fixed some issues, prepared refactoring, prepared publishing to npm finally
@@ -174,4 +182,4 @@ that file can be edited or just uploaded to [webtranslateit](http://docs.webtran
* 0.3.0: added configure and init with express support (calling guessLanguage() via 'accept-language')
* 0.2.0: added plurals
* 0.1.0: added tests
-* 0.0.1: start
+* 0.0.1: start
View
11 i18n.js
@@ -13,6 +13,7 @@ var vsprintf = require('sprintf').vsprintf,
path = require('path'),
locales = {},
defaultLocale = 'en',
+ updateFiles = true,
cookiename = null,
debug = false,
verbose = false,
@@ -44,6 +45,11 @@ i18n.configure = function (opt) {
directory = './locales';
}
+ // write new locale information to disk
+ if (typeof opt.updateFiles === 'boolean') {
+ updateFiles = opt.updateFiles
+ }
+
// where to store json files
if (typeof opt.extension === 'string') {
extension = opt.extension;
@@ -250,6 +256,11 @@ function read(locale) {
// try writing a file in a created directory
function write(locale) {
+ // don't write new locale information to disk if updateFiles isn't true
+ if(!updateFiles) {
+ return;
+ }
+
// creating directory if necessary
try {
var stats = fs.lstatSync(directory);
Please sign in to comment.
Something went wrong with that request. Please try again.