-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
837 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const PO = require('./PO'); | ||
const JSON = require('./JSON'); | ||
const JSON5 = require('./JSON5'); | ||
const CSV = require('./CSV'); | ||
|
||
const formatHandler = new Map([ | ||
['po', PO], | ||
['json', JSON], | ||
['json5', JSON5], | ||
['csv', CSV], | ||
]); | ||
|
||
class LocaleDirectory { | ||
constructor(directoryPath) { | ||
this.directoryPath = directoryPath; | ||
} | ||
|
||
buildFilename(locale, format) { | ||
const basename = [locale, format].filter(p => p).join('.'); | ||
|
||
return path.resolve(this.directoryPath, `${basename}`); | ||
} | ||
|
||
writeFile(locale, localization, format) { | ||
const filename = this.buildFilename(locale, format); | ||
const handler = formatHandler.get(format); | ||
const data = handler.stringify(localization); | ||
|
||
fs.writeSync(filename, data); | ||
} | ||
|
||
readFile(locale, format) { | ||
const filename = this.buildFilename(locale, format); | ||
const handler = formatHandler.get(format); | ||
const data = fs.readSync(filename); | ||
|
||
return handler.parse(data); | ||
} | ||
|
||
normalizeTo(format) { | ||
formatHandler.entries().forEach(([extension, handler]) => { | ||
if (extension !== format) { | ||
} | ||
}); | ||
} | ||
} | ||
|
||
module.exports = LocaleDirectory; |
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,4 @@ | ||
class CSV { | ||
} | ||
|
||
module.exports = CSV; |
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,4 @@ | ||
class JSON { | ||
} | ||
|
||
module.exports = JSON; |
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,4 @@ | ||
class JSON5 { | ||
} | ||
|
||
module.exports = JSON5; |
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,56 @@ | ||
TODO Need to parse comments like /**/ and // | ||
class PO { | ||
static read(locale, string) { | ||
} | ||
|
||
static write(locale, string) { | ||
} | ||
} | ||
/* | ||
///* This is the first comment. */ | ||
//gettext ("foo"); | ||
// | ||
///* This is the second comment: not extracted */ | ||
//gettext ( | ||
//"bar"); | ||
// | ||
//gettext ( | ||
///* This is the third comment. */ | ||
//"baz"); | ||
/* | ||
* | ||
* | ||
* | ||
white-space | ||
# translator-comments | ||
#. extracted-comments | ||
#: reference… | ||
#, flag… | ||
#| msgid previous-untranslated-string | ||
msgid untranslated-string | ||
msgstr translated-string | ||
#. NEW | ||
#: lib/error.c:116 | ||
msgctxt "Context" | ||
msgid "Unknown system error" | ||
msgstr "" | ||
"<b>Tip</b><br/>Some non-Meade telescopes support a subset of the LX200 " | ||
"command set. Select <tt>LX200 Basic</tt> to control such devices." | ||
msgstr "" | ||
#: ../src/waei/application.c:140 ../src/gwaei/application.c:234 | ||
#, kde-format | ||
msgid "Time: %1 second" | ||
msgid_plural "Time: %1 seconds" | ||
msgstr[0] "" | ||
msgstr[1] "" | ||
#~ msgid "Set the telescope longitude and latitude." | ||
#~ msgstr "Postavi geo. dužinu i širinu teleskopa." | ||
*/ | ||
|
||
module.exports = PO; |
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,15 @@ | ||
const commentCharacters = new Set([ | ||
"/*", | ||
"//" | ||
]); | ||
|
||
/** | ||
* Conveneince function to check for comment character patterns | ||
* @param {String} character - A character to check in the comment list | ||
* @return {Boolean} true if the character will cause characters after it to | ||
* not execute their usual meaning. | ||
* @private | ||
*/ | ||
module.exports = function isCommentCharacter(character) { | ||
return commentCharacters.has(character); | ||
} |
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,14 @@ | ||
const commentCharacters = new Set([ | ||
"//", | ||
'/*' | ||
]); | ||
|
||
/** | ||
* Convenience method for checking for comment characters. | ||
* @param {String} character - A character pattern to check if is a comment | ||
* @return {Boolean} True if it is a comment character for javascript | ||
* @private | ||
*/ | ||
module.exports = function isCommentStartCharacter(character) { | ||
return commentCharacters.has(character); | ||
} |
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
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,5 @@ | ||
const parseLocalizationFunction = require('./parseLocalizationFunction'); | ||
|
||
describe('parseLocalizationFunction', () => { | ||
}); | ||
|
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,13 @@ | ||
|
||
function peek(text, iterator, fn) { | ||
const readCharacter = require('./readCharacter'); | ||
const nextIterator = readCharacter(text, iterator); | ||
|
||
if (fn(nextIterator)) { | ||
return nextIterator; | ||
} | ||
|
||
return iterator; | ||
} | ||
|
||
module.exports = peek; |
Oops, something went wrong.