Initial commit
This commit is contained in:
		
							
								
								
									
										19
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								LICENSE
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | Copyright (C) 2012 Michael Holly | ||||||
|  |  | ||||||
|  | Permission is hereby granted, free of charge, to any person obtaining a copy of | ||||||
|  | this software and associated documentation files (the "Software"), to deal in | ||||||
|  | the Software without restriction, including without limitation the rights to | ||||||
|  | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||||||
|  | of the Software, and to permit persons to whom the Software is furnished to do | ||||||
|  | so, subject to the following conditions: | ||||||
|  |  | ||||||
|  | The above copyright notice and this permission notice shall be included in all | ||||||
|  | copies or substantial portions of the Software. | ||||||
|  |  | ||||||
|  | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||||
|  | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||||
|  | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||||
|  | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||||
|  | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||||
|  | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||||
|  | SOFTWARE. | ||||||
							
								
								
									
										50
									
								
								lib/extras.po
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								lib/extras.po
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | |||||||
|  | msgid "" | ||||||
|  | msgstr "" | ||||||
|  | "Project-Id-Version: PROJECT VERSION\n" | ||||||
|  | "POT-Creation-Date: 2011-08-12 09:55-0700\n" | ||||||
|  | "PO-Revision-Date: 2011-12-21 22:30-0800\n" | ||||||
|  | "Last-Translator: Mike Holly <mikejholly@gmail.com>\n" | ||||||
|  | "Language-Team: LANGUAGE <EMAIL@ADDRESS>\n" | ||||||
|  | "MIME-Version: 1.0\n" | ||||||
|  | "Content-Type: text/plain; charset=utf-8\n" | ||||||
|  | "Content-Transfer-Encoding: 8bit\n" | ||||||
|  | "Plural-Forms: nplurals=2; plural=n>1;\n" | ||||||
|  |  | ||||||
|  | #: strutta/strutta.admin.inc:11 | ||||||
|  | msgid "CSV file" | ||||||
|  | msgstr "Archivo CVS" | ||||||
|  |  | ||||||
|  | #: strutta/strutta.admin.inc:12 | ||||||
|  | msgid "Please make sure the file is formatted correctly (Name, E-mail)" | ||||||
|  | msgstr "Por favor asegúrese de que el archivo tenga el fomato correcto (Nombre, E-mail)" | ||||||
|  |  | ||||||
|  | #: strutta/strutta.admin.inc:18 | ||||||
|  | msgid "From address" | ||||||
|  | msgstr "Dirección" | ||||||
|  |  | ||||||
|  | #: strutta/strutta.admin.inc:25 | ||||||
|  | msgid "Plain text" | ||||||
|  | msgstr "Texto plano" | ||||||
|  |  | ||||||
|  | #: strutta/strutta.admin.inc:26 | ||||||
|  | msgid "HTML markup" | ||||||
|  | msgstr "Formato HTML" | ||||||
|  |  | ||||||
|  | #: strutta/strutta.admin.inc:28 | ||||||
|  | msgid "Content type" | ||||||
|  | msgstr "Tipo de contenido" | ||||||
|  |  | ||||||
|  | #: strutta_contests_client/strutta_contests_client.module:1381 | ||||||
|  | msgid "" | ||||||
|  | "There is a limit of <strong>1 vote</strong> per entry over <strong>!period</strong>. \n" | ||||||
|  | "      <br>Please come back and vote again in <strong>!retry</strong>." | ||||||
|  | msgstr "" | ||||||
|  | "Hay un límite de <strong>1 voto</strong> por entrada <strong>!period</strong>. \n" | ||||||
|  | "      <br>Por favor vuelve más tarde para votar<strong>!retry</strong>.\"" | ||||||
|  |  | ||||||
|  | #: strutta_submit/strutta_submit.module:113 | ||||||
|  | msgid "@count entry" | ||||||
|  | msgid_plural "@count entries" | ||||||
|  | msgstr[0] "@count entrada" | ||||||
|  | msgstr[1] "@count entradas" | ||||||
|  |  | ||||||
							
								
								
									
										77
									
								
								lib/po.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								lib/po.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,77 @@ | |||||||
|  | var fs = require('fs'); | ||||||
|  |  | ||||||
|  | var PO = function() { | ||||||
|  |   this.headers = {}; | ||||||
|  |   this.items = []; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | PO.prototype.write = function(filename) { | ||||||
|  |    | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | PO.load = function(filename, callback) { | ||||||
|  |   fs.readFile(filename, 'utf-8', function(err, data){ | ||||||
|  |     if (err) throw err; | ||||||
|  |     var po = new PO | ||||||
|  |       , parts = data.split(/\n\n/) | ||||||
|  |       , headers = parts.shift().split(/\n/); | ||||||
|  |      | ||||||
|  |     headers.forEach(function(header){ | ||||||
|  |       if (header.match(/^"/)) { | ||||||
|  |         var p = header.split(/:/, 2); | ||||||
|  |         po.headers[p[0].trim()] = p[1].trim(); | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |      | ||||||
|  |     parts.forEach(function(part){ | ||||||
|  |       var item = PO.Item.parse(part); | ||||||
|  |       po.items.push(item); | ||||||
|  |     }); | ||||||
|  |      | ||||||
|  |     callback(po); | ||||||
|  |   }); | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | PO.Item = function() { | ||||||
|  |   this.msgid = null; | ||||||
|  |   this.references = []; | ||||||
|  |   this.msgid_plural = null; | ||||||
|  |   this.msgstr = []; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | PO.Item.parse = function(chunk) { | ||||||
|  |    | ||||||
|  |   var item = new PO.Item(); | ||||||
|  |   var parts = chunk.split(/\nmsg/); | ||||||
|  |    | ||||||
|  |   var extract = function(string) { | ||||||
|  |     var lines = string.split(/\n/); | ||||||
|  |     var value = ''; | ||||||
|  |     lines.forEach(function(line){ | ||||||
|  |       var p = line.split(/"/); p.shift(); p.pop(); | ||||||
|  |       value += "\n" + p.join('"'); | ||||||
|  |     }); | ||||||
|  |     return value.trim(); | ||||||
|  |   }; | ||||||
|  |    | ||||||
|  |   parts.forEach(function(part){ | ||||||
|  |     if (part.match(/^#:/)) { | ||||||
|  |       item.references.push(part.replace(/^#:\s/, '')); | ||||||
|  |     } | ||||||
|  |     else if (part.match(/^id\s/)) { | ||||||
|  |       item.msgid = extract(part); | ||||||
|  |     } | ||||||
|  |     else if (part.match(/id_plural/)) { | ||||||
|  |       item.msgid_plural = extract(part); | ||||||
|  |     } | ||||||
|  |     else if (part.match(/str/)) { | ||||||
|  |       item.msgstr.push(extract(part)); | ||||||
|  |     } | ||||||
|  |   }); | ||||||
|  |  | ||||||
|  |   return item; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | PO.load('extras.po', function(po){ | ||||||
|  |   //console.log(po); | ||||||
|  | }); | ||||||
							
								
								
									
										11
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | { | ||||||
|  |   "name"          : "node-po", | ||||||
|  |   "description"   : "Simple library for loading and saving Gettext PO files.", | ||||||
|  |   "version"       : "0.1", | ||||||
|  |   "author"        : "Mike Holly", | ||||||
|  |   "homepage"      : "http://github.com/mikejholly/node-po", | ||||||
|  |   "repository"    : {"type" : "git", "url" : "http://github.com/mikejholly/node-po.git"}, | ||||||
|  |   "dependencies"  : [], | ||||||
|  |   "main"          : "./lib/po", | ||||||
|  |   "keywords"      : ["i18n", "l10n", "gettext", "mo" "po"] | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user