add some real world examples for c-strings in po files
make sure, if a file containing c-string messages is identical after being parsed and written afterwards.
This commit is contained in:
		
							
								
								
									
										19
									
								
								test/fixtures/c-strings.po
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								test/fixtures/c-strings.po
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | # French translation of Link (6.x-2.9) | ||||||
|  | # Copyright (c) 2011 by the French translation team | ||||||
|  | msgid "" | ||||||
|  | msgstr "" | ||||||
|  | "Project-Id-Version: Link (6.x-2.9)\n" | ||||||
|  | "Report-Msgid-Bugs-To: \n" | ||||||
|  | "POT-Creation-Date: 2011-12-31 23:39+0000\n" | ||||||
|  | "PO-Revision-Date: 2013-12-17 14:59+0100\n" | ||||||
|  | "Last-Translator: Ruben Vermeersch <ruben@rocketeer.be>\n" | ||||||
|  | "Language: fr\n" | ||||||
|  | "Language-Team: French\n" | ||||||
|  | "Content-Type: text/plain; charset=UTF-8\n" | ||||||
|  | "Content-Transfer-Encoding: 8bit\n" | ||||||
|  | "Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||||||
|  | "MIME-Version: 1.0\n" | ||||||
|  | "X-Generator: Poedit 1.6.2\n" | ||||||
|  |  | ||||||
|  | msgid "The name field must not contain characters like \" or \\" | ||||||
|  | msgstr "" | ||||||
| @@ -84,4 +84,21 @@ describe('Parse', function () { | |||||||
|         assert.equal(ambiguousItems[0].msgctxt, 'folder display'); |         assert.equal(ambiguousItems[0].msgctxt, 'folder display'); | ||||||
|         assert.equal(ambiguousItems[1].msgctxt, 'folder action'); |         assert.equal(ambiguousItems[1].msgctxt, 'folder action'); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  |     describe('C-Strings', function () { | ||||||
|  |         it('should parse the c-strings.po file', function () { | ||||||
|  |             var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/c-strings.po', 'utf8')); | ||||||
|  |  | ||||||
|  |             assert.notEqual(po, null); | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |         it('should extract strings containing " and \\ characters', function () { | ||||||
|  |             var po = PO.parse(fs.readFileSync(__dirname + '/fixtures/c-strings.po', 'utf8')); | ||||||
|  |  | ||||||
|  |             var items = po.items.filter(function (item) { | ||||||
|  |                 return (/^The name field must not contain/).test(item.msgid); | ||||||
|  |             }); | ||||||
|  |             assert.equal(items[0].msgid, 'The name field must not contain characters like " or \\'); | ||||||
|  |         }); | ||||||
|  |     }); | ||||||
| }); | }); | ||||||
|   | |||||||
| @@ -66,6 +66,14 @@ describe('Write', function () { | |||||||
|             item.msgid = '\\ should be written escaped'; |             item.msgid = '\\ should be written escaped'; | ||||||
|             assertHasLine(item.toString(), 'msgid "\\\\ should be written escaped"'); |             assertHasLine(item.toString(), 'msgid "\\\\ should be written escaped"'); | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|  |         it('should write identical file after parsing a file', function () { | ||||||
|  |             var input = fs.readFileSync(__dirname + '/fixtures/c-strings.po', 'utf8'); | ||||||
|  |             var po = PO.parse(input); | ||||||
|  |             var str = po.toString(); | ||||||
|  |  | ||||||
|  |             assert.equal(str, input); | ||||||
|  |         }); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     describe('msgctxt', function () { |     describe('msgctxt', function () { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user