Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
aa06a661
Commit
aa06a661
authored
Jan 08, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use unicode literals
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
47992710
Changes
48
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
48 changed files
with
769 additions
and
723 deletions
+769
-723
docs/conf.py
docs/conf.py
+14
-13
weblate/accounts/avatar.py
weblate/accounts/avatar.py
+5
-3
weblate/accounts/captcha.py
weblate/accounts/captcha.py
+5
-5
weblate/accounts/forms.py
weblate/accounts/forms.py
+3
-2
weblate/accounts/management/commands/importusers.py
weblate/accounts/management/commands/importusers.py
+2
-1
weblate/accounts/models.py
weblate/accounts/models.py
+3
-2
weblate/accounts/pipeline.py
weblate/accounts/pipeline.py
+2
-1
weblate/accounts/templatetags/authnames.py
weblate/accounts/templatetags/authnames.py
+3
-2
weblate/accounts/views.py
weblate/accounts/views.py
+2
-1
weblate/billing/admin.py
weblate/billing/admin.py
+2
-1
weblate/billing/models.py
weblate/billing/models.py
+2
-1
weblate/lang/data.py
weblate/lang/data.py
+8
-7
weblate/lang/models.py
weblate/lang/models.py
+5
-4
weblate/settings_example.py
weblate/settings_example.py
+36
-35
weblate/trans/admin_views.py
weblate/trans/admin_views.py
+2
-1
weblate/trans/autofixes/chars.py
weblate/trans/autofixes/chars.py
+5
-4
weblate/trans/autofixes/whitespace.py
weblate/trans/autofixes/whitespace.py
+2
-1
weblate/trans/checks/chars.py
weblate/trans/checks/chars.py
+24
-23
weblate/trans/checks/data.py
weblate/trans/checks/data.py
+4
-3
weblate/trans/checks/same.py
weblate/trans/checks/same.py
+2
-1
weblate/trans/checks/source.py
weblate/trans/checks/source.py
+3
-2
weblate/trans/formats.py
weblate/trans/formats.py
+3
-1
weblate/trans/forms.py
weblate/trans/forms.py
+15
-14
weblate/trans/management/commands/list_same_checks.py
weblate/trans/management/commands/list_same_checks.py
+2
-1
weblate/trans/models/advertisement.py
weblate/trans/models/advertisement.py
+2
-1
weblate/trans/models/subproject.py
weblate/trans/models/subproject.py
+2
-1
weblate/trans/models/unitdata.py
weblate/trans/models/unitdata.py
+5
-4
weblate/trans/specialchars.py
weblate/trans/specialchars.py
+354
-353
weblate/trans/templatetags/translations.py
weblate/trans/templatetags/translations.py
+7
-6
weblate/trans/tests/test_autofix.py
weblate/trans/tests/test_autofix.py
+26
-25
weblate/trans/tests/test_chars_checks.py
weblate/trans/tests/test_chars_checks.py
+47
-46
weblate/trans/tests/test_check_views.py
weblate/trans/tests/test_check_views.py
+3
-2
weblate/trans/tests/test_dictionary.py
weblate/trans/tests/test_dictionary.py
+18
-17
weblate/trans/tests/test_diff.py
weblate/trans/tests/test_diff.py
+3
-2
weblate/trans/tests/test_edit.py
weblate/trans/tests/test_edit.py
+7
-6
weblate/trans/tests/test_files.py
weblate/trans/tests/test_files.py
+3
-2
weblate/trans/tests/test_format_checks.py
weblate/trans/tests/test_format_checks.py
+83
-82
weblate/trans/tests/test_formats.py
weblate/trans/tests/test_formats.py
+8
-7
weblate/trans/tests/test_git_views.py
weblate/trans/tests/test_git_views.py
+3
-2
weblate/trans/tests/test_js_views.py
weblate/trans/tests/test_js_views.py
+5
-4
weblate/trans/tests/test_machine.py
weblate/trans/tests/test_machine.py
+5
-4
weblate/trans/tests/test_reports.py
weblate/trans/tests/test_reports.py
+2
-2
weblate/trans/tests/test_same_checks.py
weblate/trans/tests/test_same_checks.py
+9
-8
weblate/trans/tests/test_source_checks.py
weblate/trans/tests/test_source_checks.py
+2
-1
weblate/trans/tests/test_unitdata.py
weblate/trans/tests/test_unitdata.py
+3
-2
weblate/trans/tests/test_vcs.py
weblate/trans/tests/test_vcs.py
+5
-4
weblate/trans/vcs.py
weblate/trans/vcs.py
+3
-4
weblate/trans/views/reports.py
weblate/trans/views/reports.py
+10
-9
No files found.
docs/conf.py
View file @
aa06a661
...
...
@@ -12,6 +12,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
from
__future__
import
unicode_literals
import
sys
import
os
...
...
@@ -50,8 +51,8 @@ source_suffix = '.rst'
master_doc
=
'index'
# General information about the project.
project
=
u
'Weblate'
copyright
=
u
'2012 - 2015, Michal Čihař'
project
=
'Weblate'
copyright
=
'2012 - 2015, Michal Čihař'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
...
...
@@ -210,8 +211,8 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents
=
[
(
'index'
,
'Weblate.tex'
,
u
'Weblate Documentation'
,
u
'Michal Čihař'
,
'manual'
),
(
'index'
,
'Weblate.tex'
,
'Weblate Documentation'
,
'Michal Čihař'
,
'manual'
),
]
# The name of an image file (relative to this directory) to place at the top of
...
...
@@ -240,8 +241,8 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages
=
[
(
'index'
,
'weblate'
,
u
'Weblate Documentation'
,
[
u
'Michal Čihař'
],
1
)
(
'index'
,
'weblate'
,
'Weblate Documentation'
,
[
'Michal Čihař'
],
1
)
]
# If true, show URL addresses after external links.
...
...
@@ -254,8 +255,8 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents
=
[
(
'index'
,
'Weblate'
,
u
'Weblate Documentation'
,
u
'Michal Čihař'
,
'Weblate'
,
'One line description of project.'
,
(
'index'
,
'Weblate'
,
'Weblate Documentation'
,
'Michal Čihař'
,
'Weblate'
,
'One line description of project.'
,
'Miscellaneous'
),
]
...
...
@@ -275,13 +276,13 @@ texinfo_documents = [
# -- Options for Epub output ----------------------------------------------
# Bibliographic Dublin Core info.
epub_title
=
u
'Weblate Documentationt'
epub_author
=
u
'Michal Čihař'
epub_publisher
=
u
'Michal Čihař'
epub_copyright
=
u
'2012 - 2015, Michal Čihař'
epub_title
=
'Weblate Documentationt'
epub_author
=
'Michal Čihař'
epub_publisher
=
'Michal Čihař'
epub_copyright
=
'2012 - 2015, Michal Čihař'
# The basename for the epub file. It defaults to the project name.
#epub_basename =
u
'project'
#epub_basename = 'project'
# The HTML theme for the epub output. Since the default themes are not optimized
# for small screen space, using the same theme for HTML and epub output is
...
...
weblate/accounts/avatar.py
View file @
aa06a661
...
...
@@ -18,6 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
import
urllib2
import
sys
import
urllib
...
...
@@ -116,7 +118,7 @@ def get_avatar_image(user, size):
Returns avatar image from cache (if available) or downloads it.
"""
cache_key
=
u
'avatar-img-{0}-{1}'
.
format
(
cache_key
=
'avatar-img-{0}-{1}'
.
format
(
user
.
username
,
size
)
...
...
@@ -191,13 +193,13 @@ def get_user_display(user, icon=True, link=False):
'user_avatar'
,
kwargs
=
{
'user'
:
user
.
username
,
'size'
:
32
}
)
full_name
=
u
'<img src="{avatar}" class="avatar" /> {name}'
.
format
(
full_name
=
'<img src="{avatar}" class="avatar" /> {name}'
.
format
(
name
=
full_name
,
avatar
=
avatar
)
if
link
and
user
is
not
None
:
return
mark_safe
(
u
'<a href="{link}">{name}</a>'
.
format
(
return
mark_safe
(
'<a href="{link}">{name}</a>'
.
format
(
name
=
full_name
,
link
=
reverse
(
'user_page'
,
kwargs
=
{
'user'
:
user
.
username
}),
))
...
...
weblate/accounts/captcha.py
View file @
aa06a661
...
...
@@ -21,7 +21,7 @@
Simple mathematical captcha.
"""
from
__future__
import
unicode_literals
from
django.conf
import
settings
import
hashlib
...
...
@@ -47,9 +47,9 @@ class MathCaptcha(object):
'''
operators
=
(
'+'
,
'-'
,
'*'
)
operators_display
=
{
'+'
:
u
'+'
,
'-'
:
u
'-'
,
'*'
:
u
'×'
,
'+'
:
'+'
,
'-'
:
'-'
,
'*'
:
'×'
,
}
interval
=
(
1
,
10
)
...
...
@@ -118,7 +118,7 @@ class MathCaptcha(object):
Gets unicode for display.
'''
parts
=
self
.
question
.
split
()
return
u
'{0} {1} {2}'
.
format
(
return
'{0} {1} {2}'
.
format
(
parts
[
0
],
self
.
operators_display
[
parts
[
1
]],
parts
[
2
],
...
...
weblate/accounts/forms.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
itertools
import
chain
import
unicodedata
...
...
@@ -139,7 +140,7 @@ class SortedSelectMixin(object):
selected_choices, option_value, option_label
)
)
return
u
'
\
n
'.join(output)
return '
\
n
'.join(output)
class SortedSelectMultiple(SortedSelectMixin, forms.SelectMultiple):
...
...
@@ -429,7 +430,7 @@ class PasswordForm(forms.Form):
'''
if len(self.cleaned_data['
password1
']) < 6:
raise forms.ValidationError(
_(
u
'
Password
needs
to
have
at
least
six
characters
.
')
_('
Password
needs
to
have
at
least
six
characters
.
')
)
return self.cleaned_data['
password1
']
...
...
weblate/accounts/management/commands/importusers.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.contrib.auth.models
import
User
from
optparse
import
make_option
...
...
@@ -71,7 +72,7 @@ class Command(BaseCommand):
continue
if
line
[
'last_name'
]
not
in
line
[
'first_name'
]:
full_name
=
u
'{0} {1}'
.
format
(
full_name
=
'{0} {1}'
.
format
(
line
[
'first_name'
],
line
[
'last_name'
]
)
...
...
weblate/accounts/models.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
import
os
import
sys
import
binascii
...
...
@@ -382,7 +383,7 @@ class VerifiedEmail(models.Model):
email
=
models
.
EmailField
(
max_length
=
254
)
def
__unicode__
(
self
):
return
u
'{0} - {1}'
.
format
(
return
'{0} - {1}'
.
format
(
self
.
social
.
user
.
username
,
self
.
email
)
...
...
@@ -460,7 +461,7 @@ class Profile(models.Model):
'''
user
=
models
.
OneToOneField
(
User
,
unique
=
True
,
editable
=
False
)
language
=
models
.
CharField
(
verbose_name
=
_
(
u"Interface Language"
),
verbose_name
=
_
(
'Interface Language'
),
max_length
=
10
,
choices
=
settings
.
LANGUAGES
)
...
...
weblate/accounts/pipeline.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.shortcuts
import
redirect
from
django.core.urlresolvers
import
reverse
from
django.contrib.auth.models
import
User
...
...
@@ -160,7 +161,7 @@ def user_full_name(strategy, details, user=None, **kwargs):
last_name
=
details
.
get
(
'last_name'
,
''
)
if
first_name
and
first_name
not
in
last_name
:
full_name
=
u
'{0} {1}'
.
format
(
first_name
,
last_name
)
full_name
=
'{0} {1}'
.
format
(
first_name
,
last_name
)
elif
first_name
:
full_name
=
first_name
else
:
...
...
weblate/accounts/templatetags/authnames.py
View file @
aa06a661
...
...
@@ -20,6 +20,7 @@
"""
Provides user friendly names for social authentication methods.
"""
from
__future__
import
unicode_literals
from
django
import
template
from
django.utils.safestring
import
mark_safe
...
...
@@ -44,12 +45,12 @@ SOCIALS = {
'stackoverflow'
:
{
'name'
:
'Stack Overflow'
,
'fa_icon'
:
'stackoverflow'
},
}
FA_SOCIAL_TEMPLATE
=
u
'''
FA_SOCIAL_TEMPLATE
=
'''
<i class="fa fa-lg {extra_class} fa-wl-social fa-{fa_icon}"></i>
{separator}
{name}
'''
FL_SOCIAL_TEMPLATE
=
u
'''
FL_SOCIAL_TEMPLATE
=
'''
<span class="fl fa-lg {extra_class} fl-{fl_icon}"></span>
{separator}
{name}
...
...
weblate/accounts/views.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.shortcuts
import
render
,
get_object_or_404
,
redirect
from
django.views.decorators.cache
import
cache_page
from
django.http
import
HttpResponse
...
...
@@ -110,7 +111,7 @@ def mail_admins_contact(request, subject, message, context, sender):
return
mail
=
EmailMultiAlternatives
(
u
'%s%s'
%
(
settings
.
EMAIL_SUBJECT_PREFIX
,
subject
%
context
),
'%s%s'
%
(
settings
.
EMAIL_SUBJECT_PREFIX
,
subject
%
context
),
message
%
context
,
to
=
[
a
[
1
]
for
a
in
settings
.
ADMINS
],
headers
=
{
'Reply-To'
:
sender
},
...
...
weblate/billing/admin.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.contrib
import
admin
from
django.utils.translation
import
ugettext_lazy
as
_
...
...
@@ -46,7 +47,7 @@ class BillingAdmin(admin.ModelAdmin):
search_fields
=
(
'user__username'
,
'projects__name'
)
def
list_projects
(
self
,
obj
):
return
u
','
.
join
(
obj
.
projects
.
values_list
(
'name'
,
flat
=
True
))
return
','
.
join
(
obj
.
projects
.
values_list
(
'name'
,
flat
=
True
))
list_projects
.
short_description
=
_
(
'Projects'
)
...
...
weblate/billing/models.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.db
import
models
from
django.contrib.auth.models
import
User
from
django.utils.translation
import
ugettext_lazy
as
_
...
...
@@ -56,7 +57,7 @@ class Billing(models.Model):
trial
=
models
.
BooleanField
(
default
=
False
)
def
__unicode__
(
self
):
return
u
'{0} ({1})'
.
format
(
self
.
user
,
self
.
plan
)
return
'{0} ({1})'
.
format
(
self
.
user
,
self
.
plan
)
def
count_changes
(
self
,
interval
):
return
Change
.
objects
.
filter
(
...
...
weblate/lang/data.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.utils.translation
import
pgettext_lazy
...
...
@@ -312,44 +313,44 @@ EXTRALANGS = (
),
(
'frp'
,
u
'Franco-Provençal'
,
'Franco-Provençal'
,
2
,
'(n > 1)'
,
),
(
'zh_Hant'
,
u
'Traditional Chinese'
,
'Traditional Chinese'
,
1
,
'0'
,
),
(
'zh_Hans'
,
u
'Simplified Chinese'
,
'Simplified Chinese'
,
1
,
'0'
,
),
(
'sh'
,
u
'Serbo-Croatian'
,
'Serbo-Croatian'
,
3
,
'n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 &&'
' (n%100<10 || n%100>=20) ? 1 : 2'
,
),
(
'nl_BE'
,
u
'Dutch (Belgium)'
,
'Dutch (Belgium)'
,
2
,
'(n != 1)'
,
),
(
'ba'
,
u
'Bashkir'
,
'Bashkir'
,
2
,
'(n != 1)'
,
),
(
'yi'
,
u
'Yiddish'
,
'Yiddish'
,
2
,
'(n != 1)'
,
),
...
...
weblate/lang/models.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.db
import
models
,
transaction
from
django.db.utils
import
OperationalError
from
django.utils.translation
import
ugettext
as
_
,
ugettext_lazy
...
...
@@ -313,19 +314,19 @@ class LanguageManager(models.Manager):
language
=
Language
.
objects
.
get
(
code
=
lang
)
except
Language
.
DoesNotExist
:
errors
.
append
(
u
'missing language {0}: {1} ({2})'
.
format
(
'missing language {0}: {1} ({2})'
.
format
(
lang
,
name
,
plurals
)
)
continue
if
nplurals
!=
language
.
nplurals
:
errors
.
append
(
u
'different number of plurals {0}: {1} ({2})'
.
format
(
'different number of plurals {0}: {1} ({2})'
.
format
(
lang
,
name
,
plurals
)
)
errors
.
append
(
u
'have {0}'
.
format
(
language
.
get_plural_form
())
'have {0}'
.
format
(
language
.
get_plural_form
())
)
return
errors
...
...
@@ -387,7 +388,7 @@ class Language(models.Model, PercentMixin):
def
__unicode__
(
self
):
if
self
.
show_language_code
:
return
u
'{0} ({1})'
.
format
(
return
'{0} ({1})'
.
format
(
_
(
self
.
name
),
self
.
code
)
return
_
(
self
.
name
)
...
...
weblate/settings_example.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
import
django
import
os
from
logging.handlers
import
SysLogHandler
...
...
@@ -81,40 +82,40 @@ TIME_ZONE = 'UTC'
LANGUAGE_CODE
=
'en-us'
LANGUAGES
=
(
(
'az'
,
u
'Azərbaycan'
),
(
'be'
,
u
'Беларуская'
),
(
'be@latin'
,
u
'Biełaruskaja'
),
(
'br'
,
u
'Brezhoneg'
),
(
'ca'
,
u
'Català'
),
(
'cs'
,
u
'Čeština'
),
(
'da'
,
u
'Dansk'
),
(
'de'
,
u
'Deutsch'
),
(
'en'
,
u
'English'
),
(
'el'
,
u
'Ελληνικά'
),
(
'es'
,
u
'Español'
),
(
'fi'
,
u
'Suomi'
),
(
'fr'
,
u
'Français'
),
(
'fy'
,
u
'Frysk'
),
(
'gl'
,
u
'Galego'
),
(
'he'
,
u
'עברית'
),
(
'hu'
,
u
'Magyar'
),
(
'az'
,
'Azərbaycan'
),
(
'be'
,
'Беларуская'
),
(
'be@latin'
,
'Biełaruskaja'
),
(
'br'
,
'Brezhoneg'
),
(
'ca'
,
'Català'
),
(
'cs'
,
'Čeština'
),
(
'da'
,
'Dansk'
),
(
'de'
,
'Deutsch'
),
(
'en'
,
'English'
),
(
'el'
,
'Ελληνικά'
),
(
'es'
,
'Español'
),
(
'fi'
,
'Suomi'
),
(
'fr'
,
'Français'
),
(
'fy'
,
'Frysk'
),
(
'gl'
,
'Galego'
),
(
'he'
,
'עברית'
),
(
'hu'
,
'Magyar'
),
(
'id'
,
'Indonesia'
),
(
'ja'
,
u
'日本語'
),
(
'ko'
,
u
'한국어'
),
(
'ksh'
,
u
'Kölsch'
),
(
'nl'
,
u
'Nederlands'
),
(
'pl'
,
u
'Polski'
),
(
'pt'
,
u
'Português'
),
(
'pt-br'
,
u
'Português brasileiro'
),
(
'ru'
,
u
'Русский'
),
(
'sk'
,
u
'Slovenčina'
),
(
'sl'
,
u
'Slovenščina'
),
(
'sr'
,
u
'Српски'
),
(
'sv'
,
u
'Svenska'
),
(
'tr'
,
u
'Türkçe'
),
(
'uk'
,
u
'Українська'
),
(
'zh-hans'
,
u
'简体字'
),
(
'zh-hant'
,
u
'正體字'
),
(
'ja'
,
'日本語'
),
(
'ko'
,
'한국어'
),
(
'ksh'
,
'Kölsch'
),
(
'nl'
,
'Nederlands'
),
(
'pl'
,
'Polski'
),
(
'pt'
,
'Português'
),
(
'pt-br'
,
'Português brasileiro'
),
(
'ru'
,
'Русский'
),
(
'sk'
,
'Slovenčina'
),
(
'sl'
,
'Slovenščina'
),
(
'sr'
,
'Српски'
),
(
'sv'
,
'Svenska'
),
(
'tr'
,
'Türkçe'
),
(
'uk'
,
'Українська'
),
(
'zh-hans'
,
'简体字'
),
(
'zh-hant'
,
'正體字'
),
)
SITE_ID
=
1
...
...
@@ -428,7 +429,7 @@ MT_GOOGLE_KEY = None
MT_TMSERVER
=
None
# Title of site to use
SITE_TITLE
=
u
'Weblate'
SITE_TITLE
=
'Weblate'
# URL of login
LOGIN_URL
=
'%s/accounts/login/'
%
URL_PREFIX
...
...
@@ -446,7 +447,7 @@ ANONYMOUS_USER_NAME = 'anonymous'
EMAIL_SEND_HTML
=
False
# Subject of emails includes site title
EMAIL_SUBJECT_PREFIX
=
u
'[{0}] '
.
format
(
SITE_TITLE
)
EMAIL_SUBJECT_PREFIX
=
'[{0}] '
.
format
(
SITE_TITLE
)
# Enable remote hooks
ENABLE_HOOKS
=
True
...
...
weblate/trans/admin_views.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
weblate.trans.models
import
SubProject
,
IndexUpdate
from
django.contrib.sites.models
import
Site
from
django.shortcuts
import
render
...
...
@@ -97,7 +98,7 @@ def performance(request):
len
(
settings
.
ADMINS
)
>
0
or
'noreply@weblate.org'
in
[
x
[
1
]
for
x
in
settings
.
ADMINS
],
'production-admins'
,
u
', '
.
join
([
x
[
1
]
for
x
in
settings
.
ADMINS
]),
', '
.
join
([
x
[
1
]
for
x
in
settings
.
ADMINS
]),
))
# Check offloading indexing
checks
.
append
((
...
...
weblate/trans/autofixes/chars.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
weblate.trans.autofixes.base
import
AutoFix
from
django.utils.translation
import
ugettext_lazy
as
_
...
...
@@ -30,8 +31,8 @@ class ReplaceTrailingDotsWithEllipsis(AutoFix):
name
=
_
(
'Trailing ellipsis'
)
def
fix_single_target
(
self
,
target
,
source
,
unit
):
if
source
and
source
[
-
1
]
==
u
'…'
and
target
.
endswith
(
'...'
):
return
u
'%s…'
%
target
[:
-
3
],
True
if
source
and
source
[
-
1
]
==
'…'
and
target
.
endswith
(
'...'
):
return
'%s…'
%
target
[:
-
3
],
True
return
target
,
False
...
...
@@ -45,6 +46,6 @@ class RemoveZeroSpace(AutoFix):
def
fix_single_target
(
self
,
target
,
source
,
unit
):
if
unit
.
translation
.
language
.
code
.
split
(
'_'
)[
0
]
==
'km'
:
return
target
,
False
if
u'
\
u200b
'
not
in
source
and
u
'
\
u200b
'
in
target
:
return
target
.
replace
(
u
'
\
u200b
'
,
''
),
True
if
'
\
u200b
'
not
in
source
and
'
\
u200b
'
in
target
:
return
target
.
replace
(
'
\
u200b
'
,
''
),
True
return
target
,
False
weblate/trans/autofixes/whitespace.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
import
re
from
django.utils.translation
import
ugettext_lazy
as
_
from
weblate.trans.autofixes.base
import
AutoFix
...
...
@@ -47,6 +48,6 @@ class SameBookendingWhitespace(AutoFix):
# add the whitespace around the target translation (ignore blanks)
stripped = target.strip()
if stripped:
newtarget =
u
''.join((head, stripped, tail))
newtarget = ''.join((head, stripped, tail))
return newtarget, newtarget != target
return target, False
weblate/trans/checks/chars.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.utils.translation
import
ugettext_lazy
as
_
from
weblate.trans.checks.base
import
(
TargetCheck
,
TargetCheckWithFlag
,
CountingCheck
...
...
@@ -135,31 +136,31 @@ class EndStopCheck(TargetCheck):
if
self
.
is_language
(
unit
,
(
'th'
,
)):
return
False
# Allow ... to be translated into ellipsis
if
source
.
endswith
(
'...'
)
and
target
[
-
1
]
==
u
'…'
:
if
source
.
endswith
(
'...'
)
and
target
[
-
1
]
==
'…'
:
return
False
if
self
.
is_language
(
unit
,
(
'ja'
,
))
and
source
[
-
1
]
in
(
':'
,
';'
):
# Japanese sentence might need to end with full stop
# in case it's used before list.
return
self
.
check_chars
(
source
,
target
,
-
1
,
(
u';'
,
u':'
,
u':'
,
u'.'
,
u
'。'
)
source
,
target
,
-
1
,
(
';'
,
':'
,
':'
,
'.'
,
'。'
)
)
if
self
.
is_language
(
unit
,
(
'hy'
,
)):
return
self
.
check_chars
(
source
,
target
,
-
1
,
(
u'.'
,
u'。'
,
u'।'
,
u'۔'
,
u'։'
,
u
'·'
,
u'෴'
,
u'។'
,
':'
,
u'՝'
,
'?'
,
'!'
,
u
'`'
,
'.'
,
'。'
,
'।'
,
'۔'
,
'։'
,
'·'
,
'෴'
,
'។'
,
':'
,
'՝'
,
'?'
,
'!'
,
'`'
,
)
)
if
self
.
is_language
(
unit
,
(
'hi'
,
'bn'
)):
# Using | instead of । is not typographically correct, but
# seems to be quite usual
return
self
.
check_chars
(
source
,
target
,
-
1
,
(
u'.'
,
u'।'
,
u
'|'
)
source
,
target
,
-
1
,
(
'.'
,
'।'
,
'|'
)
)
return
self
.
check_chars
(
source
,
target
,
-
1
,
(
u'.'
,
u'。'
,
u'।'
,
u'۔'
,
u'։'
,
u'·'
,
u'෴'
,
u
'។'
)
(
'.'
,
'。'
,
'।'
,
'۔'
,
'։'
,
'·'
,
'෴'
,
'។'
)
)
...
...
@@ -176,8 +177,8 @@ class EndColonCheck(TargetCheck):
colon_fr
=
(
' :'
,
' : '
,
' :'
,
' : '
,
u'
\
u00A0
:'
,
u
'
\
u00A0
: '
,
u'
\
u202F
:'
u
'
\
u202F
: '
'
\
u00A0
:'
,
'
\
u00A0
: '
,
'
\
u202F
:'
'
\
u202F
: '
)
severity
=
'warning'
...
...
@@ -192,7 +193,7 @@ class EndColonCheck(TargetCheck):
source
,
target
,
-
1
,
(
u':'
,
u'՝'
,
u
'`'
)
(
':'
,
'՝'
,
'`'
)
)
return
False
...
...
@@ -204,7 +205,7 @@ class EndColonCheck(TargetCheck):
source
,
target
,
-
1
,
(
u';'
,
u':'
,
u':'
,
u'.'
,
u
'。'
)
(
';'
,
':'
,
':'
,
'.'
,
'。'
)
)
return
False
...
...
@@ -217,7 +218,7 @@ class EndColonCheck(TargetCheck):
return
self
.
_check_hy
(
source
,
target
)
if
self
.
is_language
(
unit
,
(
'ja'
,
)):
return
self
.
_check_ja
(
source
,
target
)
return
self
.
check_chars
(
source
,
target
,
-
1
,
(
u':'
,
u':'
,
u
'៖'
))
return
self
.
check_chars
(
source
,
target
,
-
1
,
(
':'
,
':'
,
'៖'
))
class
EndQuestionCheck
(
TargetCheck
):
...
...
@@ -233,10 +234,10 @@ class EndQuestionCheck(TargetCheck):
question_fr
=
(
' ?'
,
' ? '
,
' ?'
,
' ? '
,
u'
\
u00A0
?'
,
u
'
\
u00A0
? '
,
u'
\
u202F
?'
,
u
'
\
u202F
? '
'
\
u00A0
?'
,
'
\
u00A0
? '
,
'
\
u202F
?'
,
'
\
u202F
? '
)
question_el
=
(
'?'
,
';'
,
u
';'
)
question_el
=
(
'?'
,
';'
,
';'
)
severity
=
'warning'
def
_check_fr
(
self
,
source
,
target
):
...
...
@@ -250,7 +251,7 @@ class EndQuestionCheck(TargetCheck):
source
,
target
,
-
1
,
(
u'?'
,
u'՞'
,
u
'։'
)
(
'?'
,
'՞'
,
'։'
)
)
return
False
...
...
@@ -273,7 +274,7 @@ class EndQuestionCheck(TargetCheck):
source
,
target
,
-
1
,
(
u'?'
,
u'՞'
,
u'؟'
,
u'⸮'
,
u'?'
,
u'፧'
,
u'꘏'
,
u
'⳺'
)
(
'?'
,
'՞'
,
'؟'
,
'⸮'
,
'?'
,
'፧'
,
'꘏'
,
'⳺'
)
)
...
...
@@ -290,8 +291,8 @@ class EndExclamationCheck(TargetCheck):
exclamation_fr
=
(
' !'
,
' ! '
,
' !'
,
' ! '
,
u'
\
u00A0
!'
,
u
'
\
u00A0
! '
,
u'
\
u202F
!'
,
u
'
\
u202F
! '
,
'
\
u00A0
!'
,
'
\
u00A0
! '
,
'
\
u202F
!'
,
'
\
u202F
! '
,
)
severity
=
'warning'
...
...
@@ -305,7 +306,7 @@ class EndExclamationCheck(TargetCheck):
return
False
if
self
.
is_language
(
unit
,
(
'eu'
,
)):
if
source
[
-
1
]
==
'!'
:
if
u'¡'
in
target
and
u
'!'
in
target
:
if
'¡'
in
target
and
'!'
in
target
:
return
False
if
self
.
is_language
(
unit
,
(
'hy'
,
)):
return
False
...
...
@@ -317,7 +318,7 @@ class EndExclamationCheck(TargetCheck):
source
,
target
,
-
1
,
(
u'!'
,
u'!'
,
u'՜'
,
u'᥄'
,
u'႟'
,
u
'߹'
)
(
'!'
,
'!'
,
'՜'
,
'᥄'
,
'႟'
,
'߹'
)
)
...
...
@@ -334,9 +335,9 @@ class EndEllipsisCheck(TargetCheck):
if
not
target
:
return
False
# Allow ... to be translated into ellipsis
if
source
.
endswith
(
'...'
)
and
target
[
-
1
]
==
u
'…'
:
if
source
.
endswith
(
'...'
)
and
target
[
-
1
]
==
'…'
:
return
False
return
self
.
check_chars
(
source
,
target
,
-
1
,
(
u
'…'
,
))
return
self
.
check_chars
(
source
,
target
,
-
1
,
(
'…'
,
))
class
NewlineCountingCheck
(
CountingCheck
):
...
...
@@ -362,7 +363,7 @@ class ZeroWidthSpaceCheck(TargetCheck):
def
check_single
(
self
,
source
,
target
,
unit
):
if
self
.
is_language
(
unit
,
(
'km'
,
)):
return
False
return
(
u'
\
u200b
'
in
target
)
!=
(
u
'
\
u200b
'
in
source
)
return
(
'
\
u200b
'
in
target
)
!=
(
'
\
u200b
'
in
source
)
class
MaxLengthCheck
(
TargetCheckWithFlag
):
...
...
weblate/trans/checks/data.py
View file @
aa06a661
...
...
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
# We ignore some words which are usually not translated
SAME_BLACKLIST
=
frozenset
((
...
...
@@ -834,7 +835,7 @@ SAME_BLACKLIST = frozenset((
'belgium'
,
'bengali'
,
'bodo'
,
u
'bokmål'
,
'bokmål'
,
'bosnian'
,
'brazil'
,
'breton'
,
...
...
@@ -865,7 +866,7 @@ SAME_BLACKLIST = frozenset((
'finnish'
,
'flemish'
,
'franco'
,
u
'franco-provençal'
,
'franco-provençal'
,
'french'
,
'frisian'
,
'friulian'
,
...
...
@@ -939,7 +940,7 @@ SAME_BLACKLIST = frozenset((
'polish'
,
'portugal'
,
'portuguese'
,
u
'provençal'
,
'provençal'
,
'punjabi'
,
'pushto'
,
'romanian'
,
...
...
weblate/trans/checks/same.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.utils.translation
import
ugettext_lazy
as
_
from
weblate.trans.checks.base
import
TargetCheck
from
weblate.trans.checks.format
import
(
...
...
@@ -153,7 +154,7 @@ class SameCheck(TargetCheck):
# Check special things like 1:4 1/2 or copyright
if (len(source.strip('0123456789:/,.')) <= 1 or
'(c) copyright' in lower_source or
u
'©' in source):
'©' in source):
result = True
else:
# Strip format strings
...
...
weblate/trans/checks/source.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.utils.translation
import
ugettext_lazy
as
_
from
weblate.trans.checks.base
import
SourceCheck
from
weblate.trans.models.unitdata
import
Check
...
...
@@ -51,8 +52,8 @@ class EllipsisCheck(SourceCheck):
check_id
=
'ellipsis'
name
=
_
(
'Ellipsis'
)
description
=
_
(
u
'The string uses three dots (...) '
u
'instead of an ellipsis character (…)'
'The string uses three dots (...) '
'instead of an ellipsis character (…)'
)
severity
=
'warning'
...
...
weblate/trans/formats.py
View file @
aa06a661
...
...
@@ -20,6 +20,8 @@
'''
File format specific behavior.
'''
from
__future__
import
unicode_literals
from
django.utils.translation
import
ugettext_lazy
as
_
from
translate.convert
import
po2php
from
translate.storage.lisa
import
LISAfile
...
...
@@ -224,7 +226,7 @@ class FileUnit(object):
# translate.storage.properties.propunit.gettarget
# which for some reason does not return translation
value
=
quote
.
propertiesdecode
(
self
.
unit
.
value
)
value
=
re
.
sub
(
u"
\
\
\
\
"
,
u" "
,
value
)
value
=
re
.
sub
(
'
\
\
\
\
'
,
' '
,
value
)
return
value
return
self
.
unit
.
value
else
:
...
...
weblate/trans/forms.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django
import
forms
from
django.utils.translation
import
(
ugettext_lazy
as
_
,
ugettext
,
pgettext_lazy
,
pgettext
...
...
@@ -44,35 +45,35 @@ from datetime import date
from
weblate.logger
import
LOGGER
from
weblate
import
get_doc_url
ICON_TEMPLATE
=
u
'''
ICON_TEMPLATE
=
'''
<i class="fa fa-{0}"></i> {1}
'''
BUTTON_TEMPLATE
=
u
'''
BUTTON_TEMPLATE
=
'''
<button class="btn btn-default {0}" title="{1}" {2}>{3}</button>
'''
RADIO_TEMPLATE
=
u
'''
RADIO_TEMPLATE
=
'''
<label class="btn btn-default {0}" title="{1}">
<input type="radio" name="{2}" value="{3}" {4}/>
{5}
</label>
'''
GROUP_TEMPLATE
=
u
'''
GROUP_TEMPLATE
=
'''
<div class="btn-group btn-group-xs" {0}>{1}</div>
'''
TOOLBAR_TEMPLATE
=
u
'''
TOOLBAR_TEMPLATE
=
'''
<div class="btn-toolbar pull-right flip editor-toolbar">{0}</div>
'''
EDITOR_TEMPLATE
=
u
'''
EDITOR_TEMPLATE
=
'''
<div class="translation-item">
{0}<label for="{1}">{2}</label>
{3}
</div>
'''
PLURALS_TEMPLATE
=
u
'''
PLURALS_TEMPLATE
=
'''
<p class="help-block pull-right flip"><a href="{0}">{1}</a></p>
<p class="help-block">{2}</p>
'''
COPY_TEMPLATE
=
u
'''
COPY_TEMPLATE
=
'''
data-loading-text="{0}" data-href="{1}" data-checksum="{2}"
'''
...
...
@@ -92,7 +93,7 @@ class PluralTextarea(forms.Textarea):
append
=
''
# Copy button
extra_params
=
COPY_TEMPLATE
.
format
(
ugettext
(
u
'Loading…'
),
ugettext
(
'Loading…'
),
''
.
join
((
reverse
(
'js-get'
,
kwargs
=
{
'unit_id'
:
unit
.
id
}),
append
,
...
...
@@ -123,7 +124,7 @@ class PluralTextarea(forms.Textarea):
)
)
groups
.
append
(
GROUP_TEMPLATE
.
format
(
''
,
u
'
\
n
'
.
join
(
chars
))
GROUP_TEMPLATE
.
format
(
''
,
'
\
n
'
.
join
(
chars
))
)
# RTL/LTR switch
...
...
@@ -150,11 +151,11 @@ class PluralTextarea(forms.Textarea):
groups
.
append
(
GROUP_TEMPLATE
.
format
(
'data-toggle="buttons"'
,
u
'
\
n
'
.
join
(
rtl_switch
)
'
\
n
'
.
join
(
rtl_switch
)
)
)
return
TOOLBAR_TEMPLATE
.
format
(
u
'
\
n
'
.
join
(
groups
))
return
TOOLBAR_TEMPLATE
.
format
(
'
\
n
'
.
join
(
groups
))
def
render
(
self
,
name
,
unit
,
attrs
=
None
):
'''
...
...
@@ -202,9 +203,9 @@ class PluralTextarea(forms.Textarea):
)
# Show plural equation for more strings
pluralmsg
=
u
''
pluralmsg
=
''
if
len
(
values
)
>
1
:
pluralinfo
=
u
'<abbr title="{0}">{1}</abbr>: {2}'
.
format
(
pluralinfo
=
'<abbr title="{0}">{1}</abbr>: {2}'
.
format
(
ugettext
(
'This equation identifies which plural form '
'will be used based on given count (n).'
...
...
weblate/trans/management/commands/list_same_checks.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.core.management.base
import
BaseCommand
from
django.db.models
import
Count
from
weblate.trans.models
import
Check
,
get_related_units
...
...
@@ -50,7 +51,7 @@ class Command(BaseCommand):
continue
self
.
stdout
.
write
(
u
'{0:5d} {1}'
.
format
(
'{0:5d} {1}'
.
format
(
item
[
'contentsum__count'
],
units
[
0
].
source
,
)
...
...
weblate/trans/models/advertisement.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
import
random
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.db
import
models
...
...
@@ -73,7 +74,7 @@ class AdvertisementManager(models.Manager):
text
=
text
.
format
(
url
)
elif
placement
==
Advertisement
.
PLACEMENT_MAIL_HTML
:
text
,
url
=
random
.
choice
(
self
.
_fallback_choices_html
)
text
=
u
'<a href="{0}">{1}</a>'
.
format
(
text
=
'<a href="{0}">{1}</a>'
.
format
(
url
,
text
)
else
:
...
...
weblate/trans/models/subproject.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.db
import
models
,
transaction
from
django.utils.translation
import
ugettext
as
_
,
ugettext_lazy
from
django.core.mail
import
mail_admins
...
...
@@ -906,7 +907,7 @@ class SubProject(models.Model, PercentMixin, URLMixin, PathMixin):
report_error
(
error
,
sys
.
exc_info
())
self
.
notify_merge_failure
(
str
(
error
),
u
''
.
join
(
traceback
.
format_stack
()),
''
.
join
(
traceback
.
format_stack
()),
)
raise
ParseError
(
str
(
error
))
...
...
weblate/trans/models/unitdata.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.db
import
models
from
django.db.models
import
Count
from
django.contrib.auth.models
import
User
...
...
@@ -118,7 +119,7 @@ class Suggestion(models.Model):
app_label
=
'trans'
def
__unicode__
(
self
):
return
u
'suggestion for {0} by {1}'
.
format
(
return
'suggestion for {0} by {1}'
.
format
(
self
.
contentsum
,
self
.
user
.
username
if
self
.
user
else
'unknown'
,
)
...
...
@@ -183,7 +184,7 @@ class Vote(models.Model):
vote
=
'+1'
else
:
vote
=
'-1'
return
u
'{0} for {1} by {2}'
.
format
(
return
'{0} for {1} by {2}'
.
format
(
vote
,
self
.
suggestion
,
self
.
user
.
username
,
...
...
@@ -236,7 +237,7 @@ class Comment(models.Model):
app_label
=
'trans'
def
__unicode__
(
self
):
return
u
'comment for {0} by {1}'
.
format
(
return
'comment for {0} by {1}'
.
format
(
self
.
contentsum
,
self
.
user
.
username
if
self
.
user
else
'unknown'
,
)
...
...
@@ -273,7 +274,7 @@ class Check(models.Model):
unique_together
=
(
'contentsum'
,
'project'
,
'language'
,
'check'
)
def
__unicode__
(
self
):
return
u
'{0}/{1}: {2}'
.
format
(
return
'{0}/{1}: {2}'
.
format
(
self
.
project
,
self
.
language
,
self
.
check
,
...
...
weblate/trans/specialchars.py
View file @
aa06a661
This diff is collapsed.
Click to expand it.
weblate/trans/templatetags/translations.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
django.utils.html
import
escape
,
urlize
from
django.contrib.admin.templatetags.admin_static
import
static
from
django.template.loader
import
render_to_string
...
...
@@ -44,8 +45,8 @@ from weblate.trans.checks import CHECKS
register
=
template
.
Library
()
SPACE_NL
=
u
'<span class="hlspace space-nl" title="{0}"></span><br />'
SPACE_TAB
=
u
'<span class="hlspace space-tab" title="{0}"></span>'
SPACE_NL
=
'<span class="hlspace space-nl" title="{0}"></span><br />'
SPACE_TAB
=
'<span class="hlspace space-tab" title="{0}"></span>'
WHITESPACE_RE
=
re
.
compile
(
r'( +| $|^ )'
)
NEWLINES_RE
=
re
.
compile
(
r'\r\n|\r|\n'
)
...
...
@@ -61,7 +62,7 @@ NAME_MAPPING = {
None
:
ugettext_lazy
(
'Possible configuration'
)
}
FLAG_TEMPLATE
=
u
'<i title="{0}" class="fa fa-{1}"></i>'
FLAG_TEMPLATE
=
'<i title="{0}" class="fa fa-{1}"></i>'
def
fmt_whitespace
(
value
):
...
...
@@ -126,7 +127,7 @@ def format_translation(value, language, diff=None, search_match=None,
for
variation
in
re
.
findall
(
caseless
,
value
):
value
=
re
.
sub
(
caseless
,
u
'<span class="hlmatch">{0}</span>'
.
format
(
variation
),
'<span class="hlmatch">{0}</span>'
.
format
(
variation
),
value
,
)
...
...
@@ -249,10 +250,10 @@ def admin_boolean_icon(val):
else
:
ext
=
'gif'
icon_url
=
static
(
u
'admin/img/icon-{0}.{1}'
.
format
(
TYPE_MAPPING
[
val
],
ext
)
'admin/img/icon-{0}.{1}'
.
format
(
TYPE_MAPPING
[
val
],
ext
)
)
return
mark_safe
(
u
'<img src="{url}" alt="{text}" title="{text}" />'
.
format
(
'<img src="{url}" alt="{text}" title="{text}" />'
.
format
(
url
=
icon_url
,
text
=
NAME_MAPPING
[
val
],
)
...
...
weblate/trans/tests/test_autofix.py
View file @
aa06a661
...
...
@@ -22,6 +22,7 @@
Tests for automatix fixups.
"""
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
weblate.trans.tests.test_checks
import
MockUnit
from
weblate.trans.autofixes
import
fix_target
...
...
@@ -33,85 +34,85 @@ from weblate.trans.autofixes.whitespace import SameBookendingWhitespace
class
AutoFixTest
(
TestCase
):
def
test_ellipsis
(
self
):
unit
=
MockUnit
(
source
=
u
'Foo…'
)
unit
=
MockUnit
(
source
=
'Foo…'
)
fix
=
ReplaceTrailingDotsWithEllipsis
()
self
.
assertEqual
(
fix
.
fix_target
([
'Bar...'
],
unit
),
([
u
'Bar…'
],
True
)
([
'Bar…'
],
True
)
)
self
.
assertEqual
(
fix
.
fix_target
([
'Bar... '
],
unit
),
([
u
'Bar... '
],
False
)
([
'Bar... '
],
False
)
)
def
test_no_ellipsis
(
self
):
unit
=
MockUnit
(
source
=
u
'Foo...'
)
unit
=
MockUnit
(
source
=
'Foo...'
)
fix
=
ReplaceTrailingDotsWithEllipsis
()
self
.
assertEqual
(
fix
.
fix_target
([
'Bar...'
],
unit
),
([
u
'Bar...'
],
False
)
([
'Bar...'
],
False
)
)
self
.
assertEqual
(
fix
.
fix_target
([
u
'Bar…'
],
unit
),
([
u
'Bar…'
],
False
)
fix
.
fix_target
([
'Bar…'
],
unit
),
([
'Bar…'
],
False
)
)
def
test_whitespace
(
self
):
unit
=
MockUnit
(
source
=
u
'Foo
\
n
'
)
unit
=
MockUnit
(
source
=
'Foo
\
n
'
)
fix
=
SameBookendingWhitespace
()
self
.
assertEqual
(
fix
.
fix_target
([
'Bar'
],
unit
),
([
u
'Bar
\
n
'
],
True
)
([
'Bar
\
n
'
],
True
)
)
self
.
assertEqual
(
fix
.
fix_target
([
'Bar
\
n
'
],
unit
),
([
u
'Bar
\
n
'
],
False
)
([
'Bar
\
n
'
],
False
)
)
unit
=
MockUnit
(
source
=
u
' '
)
unit
=
MockUnit
(
source
=
' '
)
self
.
assertEqual
(
fix
.
fix_target
([
' '
],
unit
),
([
' '
],
False
)
)
def
test_no_whitespace
(
self
):
unit
=
MockUnit
(
source
=
u
'Foo'
)
unit
=
MockUnit
(
source
=
'Foo'
)
fix
=
SameBookendingWhitespace
()
self
.
assertEqual
(
fix
.
fix_target
([
'Bar'
],
unit
),
([
u
'Bar'
],
False
)
([
'Bar'
],
False
)
)
self
.
assertEqual
(
fix
.
fix_target
([
'Bar
\
n
'
],
unit
),
([
u
'Bar'
],
True
)
([
'Bar'
],
True
)
)
def
test_zerospace
(
self
):
unit
=
MockUnit
(
source
=
u
'Foo
\
u200b
'
)
unit
=
MockUnit
(
source
=
'Foo
\
u200b
'
)
fix
=
RemoveZeroSpace
()
self
.
assertEqual
(
fix
.
fix_target
([
'Bar'
],
unit
),
([
u
'Bar'
],
False
)
([
'Bar'
],
False
)
)
self
.
assertEqual
(
fix
.
fix_target
([
u
'Bar
\
u200b
'
],
unit
),
([
u
'Bar
\
u200b
'
],
False
)
fix
.
fix_target
([
'Bar
\
u200b
'
],
unit
),
([
'Bar
\
u200b
'
],
False
)
)
def
test_no_zerospace
(
self
):
unit
=
MockUnit
(
source
=
u
'Foo'
)
unit
=
MockUnit
(
source
=
'Foo'
)
fix
=
RemoveZeroSpace
()
self
.
assertEqual
(
fix
.
fix_target
([
'Bar'
],
unit
),
([
u
'Bar'
],
False
)
([
'Bar'
],
False
)
)
self
.
assertEqual
(
fix
.
fix_target
([
u
'Bar
\
u200b
'
],
unit
),
([
u
'Bar'
],
True
)
fix
.
fix_target
([
'Bar
\
u200b
'
],
unit
),
([
'Bar'
],
True
)
)
def
test_fix_target
(
self
):
unit
=
MockUnit
(
source
=
u
'Foo…'
)
unit
=
MockUnit
(
source
=
'Foo…'
)
fixed
,
fixups
=
fix_target
([
'Bar...'
],
unit
)
self
.
assertEqual
(
fixed
,
[
u
'Bar…'
])
self
.
assertEqual
(
fixed
,
[
'Bar…'
])
self
.
assertEqual
(
len
(
fixups
),
1
)
self
.
assertEqual
(
unicode
(
fixups
[
0
]),
u
'Trailing ellipsis'
)
self
.
assertEqual
(
unicode
(
fixups
[
0
]),
'Trailing ellipsis'
)
weblate/trans/tests/test_chars_checks.py
View file @
aa06a661
...
...
@@ -22,6 +22,7 @@
Tests for quality checks.
"""
from
__future__
import
unicode_literals
from
unittest
import
TestCase
from
weblate.trans.checks.chars
import
(
BeginNewlineCheck
,
EndNewlineCheck
,
...
...
@@ -80,8 +81,8 @@ class EndSpaceCheckTest(CheckTestCase):
self
.
test_failure_2
=
(
'string'
,
'string '
,
''
)
def
test_french
(
self
):
self
.
do_test
(
False
,
(
'Text!'
,
u
'Texte !'
,
''
),
'fr'
)
self
.
do_test
(
True
,
(
'Text'
,
u
'Texte '
,
''
),
'fr'
)
self
.
do_test
(
False
,
(
'Text!'
,
'Texte !'
,
''
),
'fr'
)
self
.
do_test
(
True
,
(
'Text'
,
'Texte '
,
''
),
'fr'
)
class
EndStopCheckTest
(
CheckTestCase
):
...
...
@@ -95,17 +96,17 @@ class EndStopCheckTest(CheckTestCase):
self
.
test_failure_2
=
(
'string'
,
'string.'
,
''
)
def
test_japanese
(
self
):
self
.
do_test
(
False
,
(
'Text:'
,
u
'Text。'
,
''
),
'ja'
)
self
.
do_test
(
True
,
(
'Text:'
,
u
'Text'
,
''
),
'ja'
)
self
.
do_test
(
False
,
(
'Text:'
,
'Text。'
,
''
),
'ja'
)
self
.
do_test
(
True
,
(
'Text:'
,
'Text'
,
''
),
'ja'
)
def
test_hindi
(
self
):
self
.
do_test
(
False
,
(
'Text.'
,
u
'Text।'
,
''
),
'hi'
)
self
.
do_test
(
True
,
(
'Text.'
,
u
'Text'
,
''
),
'hi'
)
self
.
do_test
(
False
,
(
'Text.'
,
'Text।'
,
''
),
'hi'
)
self
.
do_test
(
True
,
(
'Text.'
,
'Text'
,
''
),
'hi'
)
def
test_armenian
(
self
):
self
.
do_test
(
False
,
(
'Text:'
,
u
'Text`'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
u'Text:'
,
u
'Text՝'
,
''
),
'hy'
)
self
.
do_test
(
True
,
(
'Text.'
,
u
'Text'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
'Text:'
,
'Text`'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
'Text:'
,
'Text՝'
,
''
),
'hy'
)
self
.
do_test
(
True
,
(
'Text.'
,
'Text'
,
''
),
'hy'
)
class
EndColonCheckTest
(
CheckTestCase
):
...
...
@@ -118,27 +119,27 @@ class EndColonCheckTest(CheckTestCase):
self
.
test_failure_2
=
(
'string'
,
'string:'
,
''
)
def
test_hy
(
self
):
self
.
do_test
(
False
,
(
'Text:'
,
u
'Texte՝'
,
''
),
'hy'
)
self
.
do_test
(
True
,
(
'Text:'
,
u
'Texte'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
'Text'
,
u
'Texte:'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
'Text:'
,
'Texte՝'
,
''
),
'hy'
)
self
.
do_test
(
True
,
(
'Text:'
,
'Texte'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
'Text'
,
'Texte:'
,
''
),
'hy'
)
def
test_japanese
(
self
):
self
.
do_test
(
False
,
(
'Text:'
,
u
'Texte。'
,
''
),
'ja'
)
self
.
do_test
(
False
,
(
'Text:'
,
'Texte。'
,
''
),
'ja'
)
def
test_japanese_ignore
(
self
):
self
.
do_test
(
False
,
(
'Text'
,
u
'Texte'
,
''
),
'ja'
)
self
.
do_test
(
False
,
(
'Text'
,
'Texte'
,
''
),
'ja'
)
def
test_french_1
(
self
):
self
.
do_test
(
False
,
(
'Text:'
,
u
'Texte : '
,
''
),
'fr'
)
self
.
do_test
(
False
,
(
'Text:'
,
'Texte : '
,
''
),
'fr'
)
def
test_french_2
(
self
):
self
.
do_test
(
False
,
(
'Text:'
,
u
'Texte :'
,
''
),
'fr'
)
self
.
do_test
(
False
,
(
'Text:'
,
'Texte :'
,
''
),
'fr'
)
def
test_french_ignore
(
self
):
self
.
do_test
(
False
,
(
'Text'
,
u
'Texte'
,
''
),
'fr'
)
self
.
do_test
(
False
,
(
'Text'
,
'Texte'
,
''
),
'fr'
)
def
test_french_wrong
(
self
):
self
.
do_test
(
True
,
(
'Text:'
,
u
'Texte:'
,
''
),
'fr'
)
self
.
do_test
(
True
,
(
'Text:'
,
'Texte:'
,
''
),
'fr'
)
class
EndQuestionCheckTest
(
CheckTestCase
):
...
...
@@ -151,29 +152,29 @@ class EndQuestionCheckTest(CheckTestCase):
self
.
test_failure_2
=
(
'string'
,
'string?'
,
''
)
def
test_hy
(
self
):
self
.
do_test
(
False
,
(
'Text?'
,
u
'Texte՞'
,
''
),
'hy'
)
self
.
do_test
(
True
,
(
'Text?'
,
u
'Texte'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
'Text'
,
u
'Texte?'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
'Text?'
,
'Texte՞'
,
''
),
'hy'
)
self
.
do_test
(
True
,
(
'Text?'
,
'Texte'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
'Text'
,
'Texte?'
,
''
),
'hy'
)
def
test_french
(
self
):
self
.
do_test
(
False
,
(
'Text?'
,
u
'Texte ?'
,
''
),
'fr'
)
self
.
do_test
(
False
,
(
'Text?'
,
u
'Texte
\
u202F
?'
,
''
),
'fr'
)
self
.
do_test
(
False
,
(
'Text?'
,
u
'Texte ?'
,
''
),
'fr'
)
self
.
do_test
(
False
,
(
'Text?'
,
'Texte ?'
,
''
),
'fr'
)
self
.
do_test
(
False
,
(
'Text?'
,
'Texte
\
u202F
?'
,
''
),
'fr'
)
self
.
do_test
(
False
,
(
'Text?'
,
'Texte ?'
,
''
),
'fr'
)
def
test_french_ignore
(
self
):
self
.
do_test
(
False
,
(
'Text'
,
u
'Texte'
,
''
),
'fr'
)
self
.
do_test
(
False
,
(
'Text'
,
'Texte'
,
''
),
'fr'
)
def
test_french_wrong
(
self
):
self
.
do_test
(
True
,
(
'Text?'
,
u
'Texte?'
,
''
),
'fr'
)
self
.
do_test
(
True
,
(
'Text?'
,
'Texte?'
,
''
),
'fr'
)
def
test_greek
(
self
):
self
.
do_test
(
False
,
(
'Text?'
,
u
'Texte;'
,
''
),
'el'
)
self
.
do_test
(
False
,
(
'Text?'
,
'Texte;'
,
''
),
'el'
)
def
test_greek_ignore
(
self
):
self
.
do_test
(
False
,
(
'Text'
,
u
'Texte'
,
''
),
'el'
)
self
.
do_test
(
False
,
(
'Text'
,
'Texte'
,
''
),
'el'
)
def
test_greek_wrong
(
self
):
self
.
do_test
(
True
,
(
'Text?'
,
u
'Texte'
,
''
),
'el'
)
self
.
do_test
(
True
,
(
'Text?'
,
'Texte'
,
''
),
'el'
)
class
EndExclamationCheckTest
(
CheckTestCase
):
...
...
@@ -186,21 +187,21 @@ class EndExclamationCheckTest(CheckTestCase):
self
.
test_failure_2
=
(
'string'
,
'string!'
,
''
)
def
test_hy
(
self
):
self
.
do_test
(
False
,
(
'Text!'
,
u
'Texte՜'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
'Text!'
,
u
'Texte'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
'Text'
,
u
'Texte!'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
'Text!'
,
'Texte՜'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
'Text!'
,
'Texte'
,
''
),
'hy'
)
self
.
do_test
(
False
,
(
'Text'
,
'Texte!'
,
''
),
'hy'
)
def
test_eu
(
self
):
self
.
do_test
(
False
,
(
'Text!'
,
u
'¡Texte!'
,
''
),
'eu'
)
self
.
do_test
(
False
,
(
'Text!'
,
'¡Texte!'
,
''
),
'eu'
)
def
test_french
(
self
):
self
.
do_test
(
False
,
(
'Text!'
,
u
'Texte !'
,
''
),
'fr'
)
self
.
do_test
(
False
,
(
'Text!'
,
'Texte !'
,
''
),
'fr'
)
def
test_french_ignore
(
self
):
self
.
do_test
(
False
,
(
'Text'
,
u
'Texte'
,
''
),
'fr'
)
self
.
do_test
(
False
,
(
'Text'
,
'Texte'
,
''
),
'fr'
)
def
test_french_wrong
(
self
):
self
.
do_test
(
True
,
(
'Text!'
,
u
'Texte!'
,
''
),
'fr'
)
self
.
do_test
(
True
,
(
'Text!'
,
'Texte!'
,
''
),
'fr'
)
class
EndEllipsisCheckTest
(
CheckTestCase
):
...
...
@@ -208,13 +209,13 @@ class EndEllipsisCheckTest(CheckTestCase):
def
setUp
(
self
):
super
(
EndEllipsisCheckTest
,
self
).
setUp
()
self
.
test_good_matching
=
(
u'string…'
,
u
'string…'
,
''
)
self
.
test_failure_1
=
(
u
'string…'
,
'string...'
,
''
)
self
.
test_failure_2
=
(
'string.'
,
u
'string…'
,
''
)
self
.
test_failure_3
=
(
'string..'
,
u
'string…'
,
''
)
self
.
test_good_matching
=
(
'string…'
,
'string…'
,
''
)
self
.
test_failure_1
=
(
'string…'
,
'string...'
,
''
)
self
.
test_failure_2
=
(
'string.'
,
'string…'
,
''
)
self
.
test_failure_3
=
(
'string..'
,
'string…'
,
''
)
def
test_translate
(
self
):
self
.
do_test
(
False
,
(
'string...'
,
u
'string…'
,
''
))
self
.
do_test
(
False
,
(
'string...'
,
'string…'
,
''
))
class
NewlineCountingCheckTest
(
CheckTestCase
):
...
...
@@ -232,9 +233,9 @@ class ZeroWidthSpaceCheckTest(CheckTestCase):
def
setUp
(
self
):
super
(
ZeroWidthSpaceCheckTest
,
self
).
setUp
()
self
.
test_good_matching
=
(
u'str
\
u200b
ing'
,
u
'str
\
u200b
ing'
,
''
)
self
.
test_failure_1
=
(
u
'str
\
u200b
ing'
,
'string'
,
''
)
self
.
test_failure_2
=
(
'string'
,
u
'str
\
u200b
ing'
,
''
)
self
.
test_good_matching
=
(
'str
\
u200b
ing'
,
'str
\
u200b
ing'
,
''
)
self
.
test_failure_1
=
(
'str
\
u200b
ing'
,
'string'
,
''
)
self
.
test_failure_2
=
(
'string'
,
'str
\
u200b
ing'
,
''
)
class
MaxLengthCheckTest
(
TestCase
):
...
...
@@ -246,8 +247,8 @@ class MaxLengthCheckTest(TestCase):
'max-length:12'
)
self
.
test_good_matching_unicode
=
(
u
'strings'
,
u
'less than 21'
,
'strings'
,
'less than 21'
,
'max-length:12'
)
...
...
weblate/trans/tests/test_check_views.py
View file @
aa06a661
...
...
@@ -22,6 +22,7 @@
Tests for check views.
"""
from
__future__
import
unicode_literals
from
weblate.trans.tests.test_views
import
ViewTestCase
from
django.core.urlresolvers
import
reverse
...
...
@@ -52,7 +53,7 @@ class ChecksViewTest(ViewTestCase):
response
=
self
.
client
.
get
(
reverse
(
'show_check'
,
kwargs
=
{
'name'
:
'ellipsis'
})
)
self
.
assertContains
(
response
,
u
'…'
)
self
.
assertContains
(
response
,
'…'
)
response
=
self
.
client
.
get
(
reverse
(
'show_check'
,
kwargs
=
{
'name'
:
'not-existing'
})
...
...
@@ -83,7 +84,7 @@ class ChecksViewTest(ViewTestCase):
kwargs
=
{
'name'
:
'ellipsis'
,
'project'
:
self
.
project
.
slug
}
)
)
self
.
assertContains
(
response
,
u
'…'
)
self
.
assertContains
(
response
,
'…'
)
response
=
self
.
client
.
get
(
reverse
(
...
...
weblate/trans/tests/test_dictionary.py
View file @
aa06a661
...
...
@@ -22,6 +22,7 @@
Tests for dictionary manipulations.
"""
from
__future__
import
unicode_literals
from
weblate.trans.tests.test_views
import
ViewTestCase
from
weblate.trans.models
import
Dictionary
from
django.core.urlresolvers
import
reverse
...
...
@@ -70,11 +71,11 @@ class DictionaryTest(ViewTestCase):
# Check they are shown
response
=
self
.
client
.
get
(
show_url
)
self
.
assertContains
(
response
,
u
'podpůrná vrstva'
)
self
.
assertContains
(
response
,
'podpůrná vrstva'
)
# Change single word
word
=
Dictionary
.
objects
.
get
(
target
=
u
'podpůrná vrstva'
)
word
.
target
=
u
'zkouška sirén'
word
=
Dictionary
.
objects
.
get
(
target
=
'podpůrná vrstva'
)
word
.
target
=
'zkouška sirén'
word
.
save
()
# Import file again with orverwriting
...
...
@@ -85,11 +86,11 @@ class DictionaryTest(ViewTestCase):
# Check entry got overwritten
response
=
self
.
client
.
get
(
show_url
)
self
.
assertContains
(
response
,
u
'podpůrná vrstva'
)
self
.
assertContains
(
response
,
'podpůrná vrstva'
)
# Change single word
word
=
Dictionary
.
objects
.
get
(
target
=
u
'podpůrná vrstva'
)
word
.
target
=
u
'zkouška sirén'
word
=
Dictionary
.
objects
.
get
(
target
=
'podpůrná vrstva'
)
word
.
target
=
'zkouška sirén'
word
.
save
()
# Import file again with adding
...
...
@@ -141,7 +142,7 @@ class DictionaryTest(ViewTestCase):
# Add word
response
=
self
.
client
.
post
(
show_url
,
{
'source'
:
'source'
,
'target'
:
u
'překlad'
}
{
'source'
:
'source'
,
'target'
:
'překlad'
}
)
# Check correct response
...
...
@@ -155,22 +156,22 @@ class DictionaryTest(ViewTestCase):
# Check they are shown
response
=
self
.
client
.
get
(
show_url
)
self
.
assertContains
(
response
,
u
'překlad'
)
self
.
assertContains
(
response
,
'překlad'
)
# Edit page
response
=
self
.
client
.
get
(
edit_url
+
dict_id_url
)
self
.
assertContains
(
response
,
u
'překlad'
)
self
.
assertContains
(
response
,
'překlad'
)
# Edit translation
response
=
self
.
client
.
post
(
edit_url
+
dict_id_url
,
{
'source'
:
'src'
,
'target'
:
u
'přkld'
}
{
'source'
:
'src'
,
'target'
:
'přkld'
}
)
self
.
assertRedirects
(
response
,
show_url
)
# Check they are shown
response
=
self
.
client
.
get
(
show_url
)
self
.
assertContains
(
response
,
u
'přkld'
)
self
.
assertContains
(
response
,
'přkld'
)
# Test deleting
response
=
self
.
client
.
post
(
delete_url
,
{
'id'
:
dict_id
})
...
...
@@ -192,7 +193,7 @@ class DictionaryTest(ViewTestCase):
)
self
.
assertContains
(
response
,
u
'addon,doplněk'
'addon,doplněk'
)
def
test_download_tbx
(
self
):
...
...
@@ -208,11 +209,11 @@ class DictionaryTest(ViewTestCase):
)
self
.
assertContains
(
response
,
u
'<term>website</term>'
'<term>website</term>'
)
self
.
assertContains
(
response
,
u
'<term>webové stránky</term>'
'<term>webové stránky</term>'
)
def
test_download_po
(
self
):
...
...
@@ -228,7 +229,7 @@ class DictionaryTest(ViewTestCase):
)
self
.
assertContains
(
response
,
u
'msgid "wizard"
\
n
msgstr "průvodce"'
'msgid "wizard"
\
n
msgstr "průvodce"'
)
def
test_list
(
self
):
...
...
@@ -251,10 +252,10 @@ class DictionaryTest(ViewTestCase):
response
=
self
.
client
.
get
(
dict_url
)
self
.
assertContains
(
response
,
'Czech'
)
self
.
assertContains
(
response
,
'1 / 7'
)
self
.
assertContains
(
response
,
u
'datový tok'
)
self
.
assertContains
(
response
,
'datový tok'
)
# Filtering by letter
response
=
self
.
client
.
get
(
dict_url
,
{
'letter'
:
'b'
})
self
.
assertContains
(
response
,
'Czech'
)
self
.
assertContains
(
response
,
'1 / 1'
)
self
.
assertContains
(
response
,
u
'datový tok'
)
self
.
assertContains
(
response
,
'datový tok'
)
weblate/trans/tests/test_diff.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
unittest
import
TestCase
from
weblate.trans.simplediff
import
html_diff
from
weblate.trans.templatetags.translations
import
format_translation
...
...
@@ -60,7 +61,7 @@ class DiffTest(TestCase):
unit
.
translation
.
subproject
.
project
.
source_language
,
diff
=
'Hello world!'
,
)[
'items'
][
0
][
'content'
],
u
'Hello wor<del>l</del>d!'
'Hello wor<del>l</del>d!'
)
def
test_fmtsearchmatch
(
self
):
...
...
@@ -70,5 +71,5 @@ class DiffTest(TestCase):
MockLanguage
(
'en'
),
search_match
=
'hello'
)[
'items'
][
0
][
'content'
],
u
'<span class="hlmatch">Hello</span> world!'
'<span class="hlmatch">Hello</span> world!'
)
weblate/trans/tests/test_edit.py
View file @
aa06a661
...
...
@@ -22,6 +22,7 @@
Tests for translation views.
"""
from
__future__
import
unicode_literals
import
time
from
django.core.urlresolvers
import
reverse
...
...
@@ -106,9 +107,9 @@ class EditTest(ViewTestCase):
response
=
self
.
edit_unit
(
'Orangutan'
,
u
'Opice má %d banán.
\
n
'
,
target_1
=
u
'Opice má %d banány.
\
n
'
,
target_2
=
u
'Opice má %d banánů.
\
n
'
,
'Opice má %d banán.
\
n
'
,
target_1
=
'Opice má %d banány.
\
n
'
,
target_2
=
'Opice má %d banánů.
\
n
'
,
)
# We should get to second message
self
.
assertRedirectsOffset
(
response
,
self
.
translate_url
,
1
)
...
...
@@ -118,15 +119,15 @@ class EditTest(ViewTestCase):
self
.
assertEqual
(
len
(
plurals
),
3
)
self
.
assertEqual
(
plurals
[
0
],
u
'Opice má %d banán.
\
n
'
,
'Opice má %d banán.
\
n
'
,
)
self
.
assertEqual
(
plurals
[
1
],
u
'Opice má %d banány.
\
n
'
,
'Opice má %d banány.
\
n
'
,
)
self
.
assertEqual
(
plurals
[
2
],
u
'Opice má %d banánů.
\
n
'
,
'Opice má %d banánů.
\
n
'
,
)
def
test_merge
(
self
):
...
...
weblate/trans/tests/test_files.py
View file @
aa06a661
...
...
@@ -22,6 +22,7 @@
Tests for import and export.
"""
from
__future__
import
unicode_literals
from
weblate.trans.tests.test_views
import
ViewTestCase
from
django.core.urlresolvers
import
reverse
from
weblate.trans.tests.utils
import
get_test_file
...
...
@@ -33,8 +34,8 @@ TEST_FUZZY_PO = get_test_file('cs-fuzzy.po')
TEST_MO
=
get_test_file
(
'cs.mo'
)
TEST_ANDROID
=
get_test_file
(
'strings-cs.xml'
)
TRANSLATION_OURS
=
u
'Nazdar světe!
\
n
'
TRANSLATION_PO
=
u
'Ahoj světe!
\
n
'
TRANSLATION_OURS
=
'Nazdar světe!
\
n
'
TRANSLATION_PO
=
'Ahoj světe!
\
n
'
class
ImportBaseTest
(
ViewTestCase
):
...
...
weblate/trans/tests/test_format_checks.py
View file @
aa06a661
This diff is collapsed.
Click to expand it.
weblate/trans/tests/test_formats.py
View file @
aa06a661
...
...
@@ -20,6 +20,7 @@
'''
File format specific behavior.
'''
from
__future__
import
unicode_literals
import
tempfile
from
StringIO
import
StringIO
from
unittest
import
TestCase
,
SkipTest
...
...
@@ -95,8 +96,8 @@ class AutoFormatTest(SimpleTestCase):
MATCH
=
'msgid_plural'
MASK
=
'po/*.po'
EXPECTED_PATH
=
'po/cs_CZ.po'
FIND
=
u
'Hello, world!
\
n
'
FIND_MATCH
=
u
'Ahoj světe!
\
n
'
FIND
=
'Hello, world!
\
n
'
FIND_MATCH
=
'Ahoj světe!
\
n
'
def
test_parse
(
self
):
storage
=
self
.
FORMAT
(
self
.
FILE
)
...
...
@@ -178,7 +179,7 @@ class PoFormatTest(AutoFormatTest):
out
=
tempfile
.
NamedTemporaryFile
()
self
.
FORMAT
.
add_language
(
out
.
name
,
'cs'
,
TEST_POT_UNICODE
)
data
=
out
.
read
().
decode
(
'utf-8'
)
self
.
assertTrue
(
u
'Michal Čihař'
in
data
)
self
.
assertTrue
(
'Michal Čihař'
in
data
)
out
.
close
()
...
...
@@ -248,7 +249,7 @@ class XliffFormatTest(XMLMixin, AutoFormatTest):
EXT
=
'xlf'
COUNT
=
4
MATCH
=
'<file target-language="cs">'
FIND_MATCH
=
u
''
FIND_MATCH
=
''
MASK
=
'loc/*/default.xliff'
EXPECTED_PATH
=
'loc/cs_CZ/default.xliff'
...
...
@@ -261,8 +262,8 @@ class RESXFormatTest(XMLMixin, AutoFormatTest):
COUNT
=
4
MASK
=
'resx/*.resx'
EXPECTED_PATH
=
'resx/cs_CZ.resx'
FIND
=
u
'Hello'
FIND_MATCH
=
u
''
FIND
=
'Hello'
FIND_MATCH
=
''
MATCH
=
'<root></root>'
def
setUp
(
self
):
...
...
@@ -299,7 +300,7 @@ class OutputTest(TestCase):
# - Newline at the end of the file
# - Embedded Unicode chars (not replaced by \uxxx versions)
# - UTF-8 file
json_expected_output
=
u
'''{
json_expected_output
=
'''{
"string_abc": "Checkbox? ☑!",
"string_xyz": "Foo Bar"
}
...
...
weblate/trans/tests/test_git_views.py
View file @
aa06a661
...
...
@@ -22,6 +22,7 @@
Tests for Git manipulation views.
"""
from
__future__
import
unicode_literals
from
weblate.trans.tests.test_views
import
ViewTestCase
from
django.core.urlresolvers
import
reverse
...
...
@@ -103,7 +104,7 @@ class GitChangeProjectTest(GitNoChangeProjectTest):
def
setUp
(
self
):
super
(
GitChangeProjectTest
,
self
).
setUp
()
self
.
change_unit
(
u
'Ahoj světe!
\
n
'
)
self
.
change_unit
(
'Ahoj světe!
\
n
'
)
class
GitChangeSubProjectTest
(
GitChangeProjectTest
):
...
...
@@ -129,7 +130,7 @@ class GitCommittedChangeProjectTest(GitNoChangeProjectTest):
def
setUp
(
self
):
super
(
GitCommittedChangeProjectTest
,
self
).
setUp
()
self
.
change_unit
(
u
'Ahoj světe!
\
n
'
)
self
.
change_unit
(
'Ahoj světe!
\
n
'
)
self
.
project
.
commit_pending
(
self
.
get_request
(
'/'
))
...
...
weblate/trans/tests/test_js_views.py
View file @
aa06a661
...
...
@@ -22,6 +22,7 @@
Tests for AJAX/JS views.
"""
from
__future__
import
unicode_literals
from
weblate.trans.tests.test_views
import
ViewTestCase
from
weblate.trans.util
import
load_class
from
weblate.trans.machine
import
MACHINE_TRANSLATION_SERVICES
...
...
@@ -80,14 +81,14 @@ class JSViewsTest(ViewTestCase):
{
'quality'
:
100
,
'service'
:
'Dummy'
,
'text'
:
u
'Nazdar světe!'
,
'source'
:
u
'Hello, world!
\
n
'
,
'text'
:
'Nazdar světe!'
,
'source'
:
'Hello, world!
\
n
'
,
},
{
'quality'
:
100
,
'service'
:
'Dummy'
,
'text'
:
u
'Ahoj světe!'
,
'source'
:
u
'Hello, world!
\
n
'
,
'text'
:
'Ahoj světe!'
,
'source'
:
'Hello, world!
\
n
'
,
},
]
)
...
...
weblate/trans/tests/test_machine.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
import
httpretty
from
django.test
import
TestCase
from
django.core.cache
import
cache
...
...
@@ -36,7 +37,7 @@ from weblate.trans.machine.weblatetm import (
WeblateSimilarTranslation
,
WeblateTranslation
)
GLOSBE_JSON
=
u
'''
GLOSBE_JSON
=
'''
{
"result":"ok",
"authors":{
...
...
@@ -58,7 +59,7 @@ GLOSBE_JSON = u'''
"from":"eng"
}
'''
.
encode
(
'utf-8'
)
MYMEMORY_JSON
=
u
'''
MYMEMORY_JSON
=
'''
\
r
\
n
{"responseData":{"translatedText":"svět"},"responseDetails":"",
"responseStatus":200,
...
...
@@ -83,7 +84,7 @@ MYMEMORY_JSON = u'''
"last-update-date":"2013-06-12 17:02:07","match":0.84}
]}
'''
.
encode
(
'utf-8'
)
AMAGAMA_JSON
=
u
'''
AMAGAMA_JSON
=
'''
[{"source": "World", "quality": 80.0, "target": "Svět", "rank": 100.0}]
'''
.
encode
(
'utf-8'
)
GOOGLE_JSON
=
'[[["violation","contravention"]]]'
...
...
@@ -172,7 +173,7 @@ class MachineTranslationTest(TestCase):
httpretty
.
register_uri
(
httpretty
.
GET
,
'http://api.microsofttranslator.com/V2/Ajax.svc/Translate'
,
body
=
u
'"svět"'
.
encode
(
'utf-8'
)
body
=
'"svět"'
.
encode
(
'utf-8'
)
)
machine
=
MicrosoftTranslation
()
...
...
weblate/trans/tests/test_reports.py
View file @
aa06a661
...
...
@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
weblate.trans.tests.test_views
import
ViewTestCase
from
weblate.trans.views.reports
import
generate_credits
,
generate_counts
from
django.core.urlresolvers
import
reverse
...
...
@@ -116,7 +116,7 @@ class ReportsTest(ViewTestCase):
'count'
:
1
,
'name'
:
'Weblate Test'
,
'words'
:
2
,
'email'
:
u
'noreply@weblate.org'
'email'
:
'noreply@weblate.org'
}]
)
...
...
weblate/trans/tests/test_same_checks.py
View file @
aa06a661
...
...
@@ -22,6 +22,7 @@
Tests for quality checks.
"""
from
__future__
import
unicode_literals
from
weblate.trans.checks.same
import
(
SameCheck
,
)
...
...
@@ -65,16 +66,16 @@ class SameCheckTest(CheckTestCase):
self
.
do_test
(
False
,
(
u
'Linux kernel'
,
u
'Linux kernel'
,
'Linux kernel'
,
'Linux kernel'
,
''
)
)
self
.
do_test
(
True
,
(
u
'Linux kernel testing image'
,
u
'Linux kernel testing image'
,
'Linux kernel testing image'
,
'Linux kernel testing image'
,
''
)
)
...
...
@@ -117,16 +118,16 @@ class SameCheckTest(CheckTestCase):
self
.
do_test
(
False
,
(
u
'(c) Copyright 2013 Michal Čihař'
,
u
'(c) Copyright 2013 Michal Čihař'
,
'(c) Copyright 2013 Michal Čihař'
,
'(c) Copyright 2013 Michal Čihař'
,
''
)
)
self
.
do_test
(
False
,
(
u
'© Copyright 2013 Michal Čihař'
,
u
'© Copyright 2013 Michal Čihař'
,
'© Copyright 2013 Michal Čihař'
,
'© Copyright 2013 Michal Čihař'
,
''
)
)
...
...
weblate/trans/tests/test_source_checks.py
View file @
aa06a661
...
...
@@ -22,6 +22,7 @@
Tests for source checks.
"""
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
weblate.trans.checks.source
import
(
OptionalPluralCheck
,
...
...
@@ -74,7 +75,7 @@ class EllipsisCheckTest(TestCase):
def
test_good
(
self
):
self
.
assertFalse
(
self
.
check
.
check_source
(
[
u
'text…'
],
[
'text…'
],
MockUnit
(),
)
)
...
...
weblate/trans/tests/test_unitdata.py
View file @
aa06a661
...
...
@@ -22,6 +22,7 @@
Tests for unitdata models.
"""
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
weblate.lang.models
import
Language
from
weblate.trans.models
import
Check
,
Project
...
...
@@ -45,13 +46,13 @@ class UnitdataTestCase(TestCase):
check
=
self
.
create_check
(
'same'
)
self
.
assertEqual
(
unicode
(
check
.
get_description
()),
u
'Source and translated strings are same'
'Source and translated strings are same'
)
self
.
assertEqual
(
check
.
get_severity
(),
'warning'
)
self
.
assertTrue
(
check
.
get_doc_url
().
endswith
(
'user/checks.html#check-same'
)
)
self
.
assertEqual
(
unicode
(
check
),
u
'test/Acholi: same'
)
self
.
assertEqual
(
unicode
(
check
),
'test/Acholi: same'
)
def
test_check_nonexisting
(
self
):
check
=
self
.
create_check
(
'-invalid-'
)
...
...
weblate/trans/tests/test_vcs.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
weblate.trans.tests.test_models
import
RepoTestCase
from
weblate.trans.vcs
import
GitRepository
,
HgRepository
,
\
RepositoryException
,
GitWithGerritRepository
,
GithubRepository
...
...
@@ -271,9 +272,9 @@ class VCSGitTest(RepoTestCase):
self
.
assertTrue
(
self
.
_class
.
get_version
()
!=
''
)
def
test_set_committer
(
self
):
self
.
repo
.
set_committer
(
u
'Foo Bar Žač'
,
'foo@example.net'
)
self
.
repo
.
set_committer
(
'Foo Bar Žač'
,
'foo@example.net'
)
self
.
assertEqual
(
self
.
repo
.
get_config
(
'user.name'
),
u
'Foo Bar Žač'
self
.
repo
.
get_config
(
'user.name'
),
'Foo Bar Žač'
)
self
.
assertEqual
(
self
.
repo
.
get_config
(
'user.email'
),
'foo@example.net'
...
...
@@ -427,10 +428,10 @@ class VCSHgTest(VCSGitTest):
self
.
check_valid_info
(
info
)
def
test_set_committer
(
self
):
self
.
repo
.
set_committer
(
u
'Foo Bar Žač'
,
'foo@example.net'
)
self
.
repo
.
set_committer
(
'Foo Bar Žač'
,
'foo@example.net'
)
self
.
assertEqual
(
self
.
repo
.
get_config
(
'ui.username'
),
u
'Foo Bar Žač <foo@example.net>'
'Foo Bar Žač <foo@example.net>'
)
def
test_status
(
self
):
...
...
weblate/trans/vcs.py
View file @
aa06a661
...
...
@@ -20,6 +20,7 @@
"""
Minimal distributed version control system abstraction for Weblate needs.
"""
from
__future__
import
unicode_literals
import
subprocess
import
os
import
os.path
...
...
@@ -787,7 +788,7 @@ class HgRepository(Repository):
"""
self.set_config(
'
ui
.
username
',
u
'
{
0
}
<
{
1
}
>
'.format(
'
{
0
}
<
{
1
}
>
'.format(
name,
mail
)
...
...
@@ -933,9 +934,7 @@ class HgRepository(Repository):
output = cls._popen(['
version
', '
-
q
'])
matches = cls.VERSION_RE.match(output)
if matches is None:
raise OSError(
u'
Failed
to
parse
version
string
:
{
0
}
'.format(output)
)
raise OSError('
Failed
to
parse
version
string
:
{
0
}
'.format(output))
return matches.group(1)
def commit(self, message, author=None, timestamp=None, files=None):
...
...
weblate/trans/views/reports.py
View file @
aa06a661
...
...
@@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
__future__
import
unicode_literals
from
weblate.trans.models.changes
import
Change
from
weblate.trans.forms
import
ReportsForm
from
weblate.trans.views.helper
import
get_subproject
...
...
@@ -74,9 +75,9 @@ def get_credits(request, project, subproject):
if
form
.
cleaned_data
[
'style'
]
==
'html'
:
start
=
'<table>'
row_start
=
'<tr>'
language_format
=
u
'<th>{0}</th>'
language_format
=
'<th>{0}</th>'
translator_start
=
'<td><ul>'
translator_format
=
u
'<li><a href="mailto:{0}">{1}</a></li>'
translator_format
=
'<li><a href="mailto:{0}">{1}</a></li>'
translator_end
=
'</ul></td>'
row_end
=
'</tr>'
mime
=
'text/html'
...
...
@@ -84,9 +85,9 @@ def get_credits(request, project, subproject):
else
:
start
=
''
row_start
=
''
language_format
=
u
'* {0}
\
n
'
language_format
=
'* {0}
\
n
'
translator_start
=
''
translator_format
=
u
' * {1} <{0}>'
translator_format
=
' * {1} <{0}>'
translator_end
=
''
row_end
=
''
mime
=
'text/plain'
...
...
@@ -101,7 +102,7 @@ def get_credits(request, project, subproject):
result
.
append
(
row_start
)
result
.
append
(
language_format
.
format
(
name
))
result
.
append
(
u
'{0}{1}{2}'
.
format
(
'{0}{1}{2}'
.
format
(
translator_start
,
'
\
n
'
.
join
(
[
translator_format
.
format
(
*
t
)
for
t
in
translators
]
...
...
@@ -177,7 +178,7 @@ def get_counts(request, project, subproject):
'<th>Words</th><th>Count</th></tr>'
)
row_start
=
'<tr>'
cell_name
=
cell_email
=
cell_words
=
cell_count
=
u
'<td>{0}</td>
\
n
'
cell_name
=
cell_email
=
cell_words
=
cell_count
=
'<td>{0}</td>
\
n
'
row_end
=
'</tr>'
mime
=
'text/html'
end
=
'</table>'
...
...
@@ -196,8 +197,8 @@ def get_counts(request, project, subproject):
'Count'
)
row_start
=
''
cell_name
=
cell_email
=
u
'{0:40} '
cell_words
=
cell_count
=
u
'{0:10} '
cell_name
=
cell_email
=
'{0:40} '
cell_words
=
cell_count
=
'{0:10} '
row_end
=
''
mime
=
'text/plain'
end
=
heading
...
...
@@ -210,7 +211,7 @@ def get_counts(request, project, subproject):
if
row_start
:
result
.
append
(
row_start
)
result
.
append
(
u
'{0}{1}{2}{3}'
.
format
(
'{0}{1}{2}{3}'
.
format
(
cell_name
.
format
(
item
[
'name'
]),
cell_email
.
format
(
item
[
'email'
]),
cell_words
.
format
(
item
[
'words'
]),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment