mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Merged revisions 81697 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81697 | martin.v.loewis | 2010-06-04 20:04:42 +0200 (Fr, 04 Jun 2010) | 2 lines Issue #5464: Implement plural forms in msgfmt.py. ........
This commit is contained in:
		
							parent
							
								
									0b99883547
								
							
						
					
					
						commit
						cb081b838f
					
				
					 2 changed files with 27 additions and 2 deletions
				
			
		| 
						 | 
					@ -1548,6 +1548,8 @@ Tests
 | 
				
			||||||
Tools/Demos
 | 
					Tools/Demos
 | 
				
			||||||
-----------
 | 
					-----------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Issue #5464: Implement plural forms in msgfmt.py.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- iobench (a file I/O benchmark) and ccbench (a concurrency benchmark) were
 | 
					- iobench (a file I/O benchmark) and ccbench (a concurrency benchmark) were
 | 
				
			||||||
  added to the `Tools/` directory.  They were previously living in the
 | 
					  added to the `Tools/` directory.  They were previously living in the
 | 
				
			||||||
  sandbox.
 | 
					  sandbox.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -132,15 +132,38 @@ def make(filename, outfile):
 | 
				
			||||||
        if l[0] == '#':
 | 
					        if l[0] == '#':
 | 
				
			||||||
            continue
 | 
					            continue
 | 
				
			||||||
        # Now we are in a msgid section, output previous section
 | 
					        # Now we are in a msgid section, output previous section
 | 
				
			||||||
        if l.startswith('msgid'):
 | 
					        if l.startswith('msgid') and not l.startswith('msgid_plural'):
 | 
				
			||||||
            if section == STR:
 | 
					            if section == STR:
 | 
				
			||||||
                add(msgid, msgstr, fuzzy)
 | 
					                add(msgid, msgstr, fuzzy)
 | 
				
			||||||
            section = ID
 | 
					            section = ID
 | 
				
			||||||
            l = l[5:]
 | 
					            l = l[5:]
 | 
				
			||||||
            msgid = msgstr = ''
 | 
					            msgid = msgstr = ''
 | 
				
			||||||
 | 
					            is_plural = False
 | 
				
			||||||
 | 
					        # This is a message with plural forms
 | 
				
			||||||
 | 
					        elif l.startswith('msgid_plural'):
 | 
				
			||||||
 | 
					            if section != ID:
 | 
				
			||||||
 | 
					                print('msgid_plural not preceeded by msgid on %s:%d' % (infile, lno),
 | 
				
			||||||
 | 
					                      file=sys.stderr)
 | 
				
			||||||
 | 
					                sys.exit(1)
 | 
				
			||||||
 | 
					            l = l[12:]
 | 
				
			||||||
 | 
					            msgid += '\0' # separator of singular and plural
 | 
				
			||||||
 | 
					            is_plural = True
 | 
				
			||||||
        # Now we are in a msgstr section
 | 
					        # Now we are in a msgstr section
 | 
				
			||||||
        elif l.startswith('msgstr'):
 | 
					        elif l.startswith('msgstr'):
 | 
				
			||||||
            section = STR
 | 
					            section = STR
 | 
				
			||||||
 | 
					            if l.startswith('msgstr['):
 | 
				
			||||||
 | 
					                if not is_plural:
 | 
				
			||||||
 | 
					                    print(sys.stderr, 'plural without msgid_plural on %s:%d' % (infile, lno),
 | 
				
			||||||
 | 
					                          file=sys.stderr)
 | 
				
			||||||
 | 
					                    sys.exit(1)
 | 
				
			||||||
 | 
					                l = l.split(']', 1)[1]
 | 
				
			||||||
 | 
					                if msgstr:
 | 
				
			||||||
 | 
					                    msgstr += '\0' # Separator of the various plural forms
 | 
				
			||||||
 | 
					            else:
 | 
				
			||||||
 | 
					                if is_plural:
 | 
				
			||||||
 | 
					                    print(sys.stderr, 'indexed msgstr required for plural on  %s:%d' % (infile, lno),
 | 
				
			||||||
 | 
					                          file=sys.stderr)
 | 
				
			||||||
 | 
					                    sys.exit(1)
 | 
				
			||||||
                l = l[6:]
 | 
					                l = l[6:]
 | 
				
			||||||
        # Skip empty lines
 | 
					        # Skip empty lines
 | 
				
			||||||
        l = l.strip()
 | 
					        l = l.strip()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue