-
Notifications
You must be signed in to change notification settings - Fork 154
Globalization #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Globalization #139
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -15,3 +15,7 @@ npm-debug.log | |
| .idea | ||
| node_modules | ||
| providers-private.json | ||
|
|
||
| !intl/ | ||
| intl/* | ||
| !intl/en/ | ||
This file contains hidden or 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 hidden or 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,10 @@ | ||
| { | ||
| "2eb418c4dc7f7a3e989bb71a8f5388d7": "{{FileSystemProvider}}: Path does not exist: {0}", | ||
| "6af59b6408b92f4c6b13a2c9b06379f2": "{{FileSystemProvider}}: Invalid name: {0}", | ||
| "95065f7f9499f75f49e3714aa4e2031d": "{{FileSystemProvider}}: Invalid name: ", | ||
| "c9fb0aba850059a14f4ed5e045e4ec3e": "Invalid name: {0}", | ||
| "f589fe721f4e6fa112d1f66081ed29ac": "{{FileSystemProvider}}: Invalid directory: {0}", | ||
| "45c1c136e750c62179d75a1c99151281": "{{maxFileSize}} exceeded, received {0} bytes of field data (max is {1})", | ||
| "78f6f36e8300e15cff778496fb1dd178": "{{contentType}} \"{0}\" is not allowed (Must be in [{1}])", | ||
| "b8a9e184534171cf66caf58d29ad76f5": "{{maxFieldsSize}} exceeded, received {0} bytes of field data" | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -3,6 +3,9 @@ | |
| // This file is licensed under the Artistic License 2.0. | ||
| // License text available at https://opensource.org/licenses/Artistic-2.0 | ||
|
|
||
| // Globalization | ||
| var g = require('strong-globalize')(); | ||
|
|
||
| /** | ||
| * File system based on storage provider | ||
| */ | ||
|
|
@@ -27,21 +30,21 @@ function FileSystemProvider(options) { | |
| this.root = options.root; | ||
| var exists = fs.existsSync(this.root); | ||
| if (!exists) { | ||
| throw new Error('FileSystemProvider: Path does not exist: ' + this.root); | ||
| throw new Error(g.f('{{FileSystemProvider}}: Path does not exist: %s', this.root)); | ||
| } | ||
| var stat = fs.statSync(this.root); | ||
| if (!stat.isDirectory()) { | ||
| throw new Error('FileSystemProvider: Invalid directory: ' + this.root); | ||
| throw new Error(g.f('{{FileSystemProvider}}: Invalid directory: %s', this.root)); | ||
| } | ||
| } | ||
|
|
||
| var namePattern = new RegExp('[^' + path.sep + '/]+'); | ||
|
|
||
| function validateName(name, cb) { | ||
| if (!name) { | ||
| cb && process.nextTick(cb.bind(null, new Error('Invalid name: ' + name))); | ||
| cb && process.nextTick(cb.bind(null, new Error(g.f('Invalid name: %s', name)))); | ||
| if (!cb) { | ||
| console.error('FileSystemProvider: Invalid name: ', name); | ||
| console.error(g.f('{{FileSystemProvider}}: Invalid name: %s', name)); | ||
| } | ||
| return false; | ||
| } | ||
|
|
@@ -50,9 +53,9 @@ function validateName(name, cb) { | |
| return true; | ||
| } else { | ||
| cb && process.nextTick(cb.bind(null, | ||
| new Error('FileSystemProvider: Invalid name: ' + name))); | ||
| new Error(g.f('{{FileSystemProvider}}: Invalid name: %s', name)))); | ||
| if (!cb) { | ||
| console.error('FileSystemProvider: Invalid name: ', name); | ||
| console.error(g.f('{{FileSystemProvider}}: Invalid name: ', name)); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
| return false; | ||
| } | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -3,6 +3,9 @@ | |
| // This file is licensed under the Artistic License 2.0. | ||
| // License text available at https://opensource.org/licenses/Artistic-2.0 | ||
|
|
||
| // Globalization | ||
| var g = require('strong-globalize')(); | ||
|
|
||
| var IncomingForm = require('formidable'); | ||
| var StringDecoder = require('string_decoder').StringDecoder; | ||
| var path = require('path'); | ||
|
|
@@ -43,7 +46,7 @@ exports.upload = function(provider, req, res, options, cb) { | |
| part.on('data', function(buffer) { | ||
| self._fieldsSize += buffer.length; | ||
| if (self._fieldsSize > self.maxFieldsSize) { | ||
| self._error(new Error('maxFieldsSize exceeded, received ' + self._fieldsSize + ' bytes of field data')); | ||
| self._error(new Error(g.f('{{maxFieldsSize}} exceeded, received %s bytes of field data', self._fieldsSize))); | ||
| return; | ||
| } | ||
| value += decoder.write(buffer); | ||
|
|
@@ -88,7 +91,7 @@ exports.upload = function(provider, req, res, options, cb) { | |
| } | ||
| if (Array.isArray(allowedContentTypes) && allowedContentTypes.length !== 0) { | ||
| if (allowedContentTypes.indexOf(file.type) === -1) { | ||
| self._error(new Error('contentType "' + file.type + '" is not allowed (Must be in [' + allowedContentTypes.join(', ') + '])')); | ||
| self._error(new Error(g.f('{{contentType}} "%s" is not allowed (Must be in [%s])', file.type, allowedContentTypes.join(', ')))); | ||
| return; | ||
| } | ||
| } | ||
|
|
@@ -155,7 +158,7 @@ exports.upload = function(provider, req, res, options, cb) { | |
| // We are missing some way to tell the provider to cancel upload/multipart upload of the current file. | ||
| // - s3-upload-stream doesn't provide a way to do this in it's public interface | ||
| // - We could call provider.delete file but it would not delete multipart data | ||
| self._error(new Error('maxFileSize exceeded, received ' + fileSize + ' bytes of field data (max is ' + maxFileSize + ')')); | ||
| self._error(new Error(g.f('{{maxFileSize}} exceeded, received %s bytes of field data (max is %s)', fileSize, maxFileSize))); | ||
| return; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should add brackets {{maxFileSize}} |
||
| } | ||
| }); | ||
|
|
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add brackets {{FileSystemProvider}} for strings that don't need to be translated.