Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
d87e1a59
Unverified
Commit
d87e1a59
authored
7 years ago
by
Martin Trigaux
Browse files
Options
Downloads
Patches
Plain Diff
[IMP] doc: translation documentation
Update screenshot for v11 Give examples of Do/Don't
parent
046e4ee2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/reference/translations.rst
+92
-5
92 additions, 5 deletions
doc/reference/translations.rst
doc/reference/translations/po-export.png
+0
-0
0 additions, 0 deletions
doc/reference/translations/po-export.png
with
92 additions
and
5 deletions
doc/reference/translations.rst
+
92
−
5
View file @
d87e1a59
...
...
@@ -86,13 +86,100 @@ In JavaScript, the wrapping function is generally :js:func:`odoo.web._t`:
Only literal strings can be marked for exports, not expressions or
variables. For situations where strings are formatted, this means the
format string must be marked, not the formatted string
::
format string must be marked, not the formatted string
# bad, the extract may work but it will not translate the text correctly
_("Scheduled meeting with %s" % invitee.name)
# good
_("Scheduled meeting with %s") % invitee.name
Variables
^^^^^^^^^
**Don't** the extract may work but it will not translate the text correctly::
_("Scheduled meeting with %s" % invitee.name)
**Do** set the dynamic variables outside of the translation lookup::
_("Scheduled meeting with %s") % invitee.name
Blocks
^^^^^^
**Don't** split your translation in several blocks or multiples lines::
# bad, trailing spaces, blocks out of context
_("You have ") + len(invoices) + _(" invoices waiting")
# bad, multiple small translations
_("Reference of the document that generated ") + \
_("this sales order request.")
**Do** keep in one block, giving the full context to translators::
# good, allow to change position of the number in the translation
_("You have %s invoices wainting") % len(invoices)
# good, full sentence is understandable
_("Reference of the document that generated " + \
"this sales order request.")
Plural
^^^^^^
**Don't** pluralize terms the English-way::
msg = _("You have %s invoice") % invoice_count
if invoice_count > 1:
msg += _("s")
**Do** keep in mind every language has different plural forms::
if invoice_count > 1:
msg = _("You have %s invoices") % invoice_count
else:
msg = _("You have %s invoice") % invoice_count
Lazy
^^^^
**Don't** invoke translation lookup at server launch::
ERROR_MESSAGE = {
# bad, evaluated at server launch with no user language
access_error: _('Access Error'),
missing_error: _('Missing Record'),
}
class Record(models.Model):
def _raise_error(self, code):
raise UserError(ERROR_MESSAGE[code])
**Don't** invoke translation lookup before loading the translation memory::
# bad, js _t is evaluated too early
var core = require('web.core');
var _t = core._t;
var map_title = {
access_error: _t('Access Error'),
missing_error: _t('Missing Record'),
};
**Do** evaluate dynamically the translatable content::
# good, evaluated at run time
def _get_error_message():
return {
access_error: _('Access Error'),
missing_error: _('Missing Record'),
}
**Do** use `_lt` for lazy-loading::
# good, js _lt is evaluated lazily
var core = require('web.core');
var _lt = core._lt;
var map_title = {
access_error: _lt('Access Error'),
missing_error: _lt('Missing Record'),
};
.. _PO File: http://en.wikipedia.org/wiki/Gettext#Translating
.. _msginit: http://www.gnu.org/software/gettext/manual/gettext.html#Creating
...
...
This diff is collapsed.
Click to expand it.
doc/reference/translations/po-export.png
+
0
−
0
View replaced file @
046e4ee2
View file @
d87e1a59
5.93 KiB
|
W:
|
H:
12.2 KiB
|
W:
|
H:
2-up
Swipe
Onion skin
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment