Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Weblate
gajim
Commits
cf0bc0b4
Commit
cf0bc0b4
authored
14 years ago
by
Alexander Cherniuk
Browse files
Options
Downloads
Patches
Plain Diff
Refactored the Q_ translation function
parent
d5a6a4d5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/i18n.py
+19
-14
19 additions, 14 deletions
src/common/i18n.py
with
19 additions
and
14 deletions
src/common/i18n.py
+
19
−
14
View file @
cf0bc0b4
...
...
@@ -67,20 +67,25 @@ if gettext._translations:
else
:
_translation
=
gettext
.
NullTranslations
()
def
Q_
(
s
):
# Qualified translatable strings
# Some strings are too ambiguous to be easily translated.
# so we must use as:
# s = Q_('?vcard:Unknown')
# widget.set_text(s)
# Q_() removes the ?vcard:
# but gettext while parsing the file detects ?vcard:Unknown as a whole string.
# translator can either put the ?vcard: part or no (easier for him or her to no)
# nothing fails
s
=
_
(
s
)
if
s
[
0
]
==
'
?
'
:
s
=
s
[
s
.
find
(
'
:
'
)
+
1
:]
# remove ?abc: part
return
s
def
Q_
(
text
):
"""
Translate the given text, optionally qualified with a special
construction, which will help translators to disambiguate between
same terms, but in different contexts.
When translated text is returned - this rudimentary construction
will be stripped off, if it
'
s present.
Here is the construction to use:
Q_(
"
?vcard:Unknown
"
)
Everything between ? and : - is the qualifier to convey the context
to the translators. Everything after : - is the text itself.
"""
text
=
_
(
text
)
if
text
.
startswith
(
'
?
'
):
qualifier
,
text
=
text
.
split
(
'
:
'
,
1
)
return
text
def
ngettext
(
s_sing
,
s_plural
,
n
,
replace_sing
=
None
,
replace_plural
=
None
):
"""
...
...
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