Skip to content

Commit

Permalink
Merge branch 'master' of github.com:nijel/weblate
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed May 10, 2012
2 parents f11b114 + 178237f commit 9e0c784
Show file tree
Hide file tree
Showing 13 changed files with 198 additions and 128 deletions.
8 changes: 8 additions & 0 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,11 @@ invoke following SQL command to adjust it:
.. code-block:: sql
ALTER TABLE `trans_subproject` ADD `template` VARCHAR(200);
Migrating from Pootle
---------------------

As Weblate was originally written as replacement from Pootle, it is supported
to migrate user accounts from Pootle. All you need to do is to copy
``auth_user`` table from Pootle, user profiles will be automatically created
for users as they log in and they will be asked to update their settings.
4 changes: 4 additions & 0 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ On translate page, you are shown source string and edit area for translating.
Should the translation be plural, multiple source strings and edit areas are
shown, each described with label for plural form.

Any special whitespace chars are underlined in red and indicated with grey
symbols. Also more than one space is underlined in red to allow translator to
keep formatting.

There are various extra information which can be shown on this page. Most of
them are coming from the project source code (like context, comments or where
the message is being used). When you configure secondary languages in your
Expand Down
13 changes: 13 additions & 0 deletions weblate/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,22 @@ def __unicode__(self):

@receiver(user_logged_in)
def set_lang(sender, **kwargs):
'''
Signal handler for setting user language and
migrating profile if needed.
'''
request = kwargs['request']
user = kwargs['user']

# Get or create profile
try:
profile = user.get_profile()
except Profile.DoesNotExist:
profile, newprofile = Profile.objects.get_or_create(user = user)
if newprofile:
messages.info(request, gettext('Your profile has been migrated, you might want to adjust preferences.'))

# Set language for session based on preferences
lang_code = user.get_profile().language
request.session['django_language'] = lang_code

Expand All @@ -71,6 +78,9 @@ def create_profile_callback(sender, **kwargs):


def create_groups(update, move):
'''
Creates standard groups and gives them permissions.
'''
group, created = Group.objects.get_or_create(name = 'Users')
if created or update:
group.permissions.add(
Expand Down Expand Up @@ -109,6 +119,9 @@ def create_groups(update, move):
u.groups.add(group)

def sync_create_groups(sender, **kwargs):
'''
Create groups on syncdb.
'''
if sender.__name__ == 'weblate.accounts.models':
create_groups(False, False)

Expand Down
10 changes: 9 additions & 1 deletion weblate/lang/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from translate.lang import data
from django.db.models.signals import post_syncdb

# Extra languages not included in ttkit
EXTRALANGS = [
('ur', 'Urdu', 2, '(n != 1)'),
('uz@latin', 'Uzbek (latin)', 1, '0'),
Expand All @@ -22,7 +23,7 @@
class LanguageManager(models.Manager):
def auto_create(self, code):
'''
Autmatically creates new language based on code and best guess
Automatically creates new language based on code and best guess
of parameters.
'''
# Create standard language
Expand Down Expand Up @@ -152,12 +153,19 @@ def get_absolute_url(self):
})

def has_translations(self):
'''
Checks whether there is a translation existing for this language.
'''
from weblate.trans.models import Translation
return Translation.objects.filter(language = self).count() > 0

def get_translated_percent(self):
'''
Returns status of translations in this language.
'''
from weblate.trans.models import Translation
translations = Translation.objects.filter(language = self).aggregate(Sum('translated'), Sum('total'))
# Prevent division by zero on no translations
if translations['total__sum'] == 0:
return 0
return round(translations['translated__sum'] * 100.0 / translations['total__sum'], 1)
5 changes: 2 additions & 3 deletions weblate/locale/cs/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: Weblate\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-05-03 15:25+0200\n"
"PO-Revision-Date: 2012-05-03 15:21+0200\n"
"PO-Revision-Date: 2012-05-03 15:27+0200\n"
"Last-Translator: Michal Čihař <michal@cihar.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: cs\n"
Expand Down Expand Up @@ -498,7 +498,7 @@ msgstr "Nebyla zaznamenána žádná nedávná aktivita."

#: html/list-translations.html:8 html/translate.html:69
msgid "Fuzzy"
msgstr "Nejasný"
msgstr "Nejasných"

#: html/list-translations.html:9 trans/views.py:76
msgid "Checks"
Expand Down Expand Up @@ -1788,7 +1788,6 @@ msgid "Plural equation"
msgstr "Rovnice množných tvarů"

#: trans/forms.py:98
#, fuzzy
msgctxt "Checkbox for marking translation fuzzy"
msgid "Fuzzy"
msgstr "Nejasný"
Expand Down
8 changes: 4 additions & 4 deletions weblate/locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: Weblate\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2012-05-03 15:25+0200\n"
"PO-Revision-Date: 2012-04-26 17:27+0200\n"
"PO-Revision-Date: 2012-05-03 17:31+0200\n"
"Last-Translator: Matías Bellone <matiasbellone@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: es\n"
Expand Down Expand Up @@ -810,9 +810,8 @@ msgid "Message is fuzzy"
msgstr "Mensaje parcial"

#: html/unit-state.html:4
#, fuzzy
msgid "Message has failing checks"
msgstr "Chequeos fallidos"
msgstr "El mensaje tiene chequeos fallidos"

#: html/unit-state.html:5
msgid "Message is translated"
Expand Down Expand Up @@ -1793,7 +1792,6 @@ msgid "Plural equation"
msgstr "Ecuación de plural"

#: trans/forms.py:98
#, fuzzy
msgctxt "Checkbox for marking translation fuzzy"
msgid "Fuzzy"
msgstr "Parcial"
Expand Down Expand Up @@ -1993,6 +1991,8 @@ msgstr "Cadenas con sugerencias (%d)"
#: trans/models.py:1115
msgid "Message not found in backend storage, it is probably corrupted."
msgstr ""
"No se encontró el mensaje almacenado en la base de datos, probablemente esté "
"corrupto."

#: trans/views.py:48
msgid "Please set your full name in your profile."
Expand Down

0 comments on commit 9e0c784

Please sign in to comment.