mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	docs/translating: Follow-on cleanups from removing Django templates.
This follows up the recent commit
3d1d09b3d docs: Remove discussion of old Django templating engine.
with a small grammar fix and removing another vestige of making the
distinction between Jinja2 and Django templates, and also rearranges
the logic slightly to reflect that backend and frontend templates
have separate sections.
Probably a bigger restructuring is in order to help the reader
navigate through all the good content in this doc, but that's
a bigger job for another day.
			
			
This commit is contained in:
		@@ -208,23 +208,18 @@ These files are uploaded to [Transifex][], where they can be translated.
 | 
			
		||||
## Backend translations
 | 
			
		||||
 | 
			
		||||
All user-facing text in the Zulip UI should be generated by an HTML
 | 
			
		||||
template so that it can be translated.
 | 
			
		||||
template so that it can be translated.  For text generated in the
 | 
			
		||||
backend, including logged-out ("portico") pages and the webapp's base
 | 
			
		||||
content, we use the [Jinja2][] template engine.
 | 
			
		||||
 | 
			
		||||
Zulip's HTML is primarily implemented using two types of HTML
 | 
			
		||||
templates: backend templates (powered by the [Jinja2][] template
 | 
			
		||||
engine used for logged-out ("portico") pages and the webapp's base
 | 
			
		||||
content) and frontend templates (powered by [Handlebars][]) used for
 | 
			
		||||
live-rendering HTML from JavaScript for things like the main message
 | 
			
		||||
feed.
 | 
			
		||||
 | 
			
		||||
To mark a string for translation in the Jinja2 template engines, you
 | 
			
		||||
To mark a string for translation in a Jinja2 template, you
 | 
			
		||||
can use the `_()` function in the templates like this:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
{{ _("English text") }}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
If a string contains both a literal string component and variables,
 | 
			
		||||
If a piece of text contains both a literal string component and variables,
 | 
			
		||||
you can use a block translation, which makes use of placeholders to
 | 
			
		||||
help translators to translate an entire sentence.  To translate a
 | 
			
		||||
block, Jinja2 uses the [trans][] tag.  So rather than writing
 | 
			
		||||
@@ -238,7 +233,6 @@ something ugly and confusing for translators like this:
 | 
			
		||||
You can instead use:
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
# Jinja2 style
 | 
			
		||||
{% trans %}This string will have {{ value }} inside.{% endtrans %}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@@ -257,11 +251,14 @@ Zulip linter (`tools/lint`) checks for correct usage.
 | 
			
		||||
 | 
			
		||||
## Frontend translations
 | 
			
		||||
 | 
			
		||||
Zulip uses the [i18next][] library for frontend translations. There
 | 
			
		||||
are two types of files in Zulip frontend which can hold translatable
 | 
			
		||||
strings: JavaScript code files and Handlebar templates. To mark a
 | 
			
		||||
string translatable in JavaScript files, pass it to the `i18n.t`
 | 
			
		||||
function.
 | 
			
		||||
For text generated in the frontend, live-rendering HTML from
 | 
			
		||||
JavaScript for things like the main message feed, we use the
 | 
			
		||||
[Handlebars][] template engine and sometimes work directly from
 | 
			
		||||
JavaScript code.  In both cases, we use the [i18next][] library
 | 
			
		||||
for translations.
 | 
			
		||||
 | 
			
		||||
To mark a string translatable in JavaScript files, pass it to the
 | 
			
		||||
`i18n.t` function.
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
i18n.t('English Text', context);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user