mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.10.x] Fixed #27069 -- Doc'd which gettext functions may be aliased as _.
Backport of 35ea6d83c8 from master
			
			
This commit is contained in:
		
				
					committed by
					
						 Tim Graham
						Tim Graham
					
				
			
			
				
	
			
			
			
						parent
						
							3db01b2d58
						
					
				
				
					commit
					04f0c2ab39
				
			| @@ -70,6 +70,16 @@ as a shorter alias, ``_``, to save typing. | ||||
|        global ``_()`` function causes interference. Explicitly importing | ||||
|        ``ugettext()`` as ``_()`` avoids this problem. | ||||
|  | ||||
| .. admonition:: What functions may be aliased as ``_``? | ||||
|  | ||||
|     Because of how ``xgettext`` (used by :djadmin:`makemessages`) works, only | ||||
|     functions that take a single string argument can be imported as ``_``: | ||||
|  | ||||
|     * :func:`~django.utils.translation.gettext` | ||||
|     * :func:`~django.utils.translation.gettext_lazy` | ||||
|     * :func:`~django.utils.translation.ugettext` | ||||
|     * :func:`~django.utils.translation.ugettext_lazy` | ||||
|  | ||||
| In this example, the text ``"Welcome to my site."`` is marked as a translation | ||||
| string:: | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user