From a8544f016db1fb484e56056e0f8cb9d76cc7930a Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Fri, 22 Jan 2016 20:46:20 +0100 Subject: [PATCH] Mark all motion state names as translatable in JS. (Fixes #1864) Updated README for how to update translations. --- openslides/locale/README.txt | 54 +++++++++-------- openslides/motions/signals.py | 58 +++++++++---------- openslides/motions/static/js/motions/base.js | 40 +++++++++++++ .../templates/motions/slide_motion.html | 2 +- 4 files changed, 101 insertions(+), 53 deletions(-) diff --git a/openslides/locale/README.txt b/openslides/locale/README.txt index a54166107..eda53dfe2 100644 --- a/openslides/locale/README.txt +++ b/openslides/locale/README.txt @@ -1,27 +1,35 @@ -Instruction to update translation for OpenSlides: -------------------------------------------------- +Instruction to update translations for OpenSlides (JavaScipt and Django): +------------------------------------------------------------------------- -1. Go to the openslides directory (which contains the 'locale' directory): +1. Update English resource files: + + a) for JavaScript run: + $ ./node_modules/.bin/gulp pot + -> updates 'openslides/locale/angular-gettext/template-en.pot' + + b) for Django: + $ cd openslides + $ django-admin.py makemessages -l en + -> updates 'openslides/locale/en/LC_MESSAGES/django.po' + +2. Commit and merge the following files into OpenSlides master repo: + a) openslides/locale/angular-gettext/template-en.pot + b) openslides/locale/en/LC_MESSAGES/django.po + + Transifex will update both resource files once a day by pulling from GitHub. + +3. Translate both files in transifex into desired languages. + https://www.transifex.com/openslides/ + +4. Download translated po files for each language and override it: + a) openslides/locale/angular-gettext/{LANG-CODE}.po + b) openslides/locale/{LANG-CODE}/LC_MESSAGES/django.po + +5. Create mo file for each language (only for django po files required) $ cd openslides - -2. Update the German po file (locale/de/LC_MESSAGES/django.po): - $ django-admin.py makemessages -l de - $ django-admin.py makemessages -l de -d djangojs - -3. Edit the German po file: locale/de/LC_MESSAGES/django.po - Don't forget the js-file: locale/de/LC_MESSAGES/djangojs.po - (Search for "fuzzy" and empty msgstr entries.) - -4. Update the German mo file (locale/de/LC_MESSAGES/django.mo): $ django-admin.py compilemessages -5. Restart server: - $ python manage.py runserver - --- -Additional hints for internationalization (i18n) in Django: -https://docs.djangoproject.com/en/dev/topics/i18n/ - -Note: gettext is required to extract message IDs or compile message files. -For gettext on Windows read: -https://docs.djangoproject.com/en/dev/topics/i18n/translation/#gettext-on-windows +6. Commit and merge for each language the following files: + a) openslides/locale/angular-gettext/{LANG-CODE}.po + b) openslides/locale/{LANG-CODE}/LC_MESSAGES/django.po + openslides/locale/{LANG-CODE}/LC_MESSAGES/django.mo diff --git a/openslides/motions/signals.py b/openslides/motions/signals.py index 113113406..35f4688aa 100644 --- a/openslides/motions/signals.py +++ b/openslides/motions/signals.py @@ -1,6 +1,6 @@ from django.core.validators import MinValueValidator from django.utils.translation import ugettext as _ -from django.utils.translation import pgettext, ugettext_lazy, ugettext_noop +from django.utils.translation import pgettext, ugettext_lazy from openslides.core.config import ConfigVariable from openslides.poll.models import PERCENT_BASE_CHOICES @@ -181,79 +181,79 @@ def create_builtin_workflows(sender, **kwargs): # If there is at least one workflow, then do nothing. return - workflow_1 = Workflow.objects.create(name=ugettext_noop('Simple Workflow')) - state_1_1 = State.objects.create(name=ugettext_noop('submitted'), + workflow_1 = Workflow.objects.create(name='Simple Workflow') + state_1_1 = State.objects.create(name='submitted', workflow=workflow_1, allow_create_poll=True, allow_support=True, allow_submitter_edit=True) - state_1_2 = State.objects.create(name=ugettext_noop('accepted'), + state_1_2 = State.objects.create(name='accepted', workflow=workflow_1, - action_word=ugettext_noop('Accept'), + action_word='Accept', css_class='success') - state_1_3 = State.objects.create(name=ugettext_noop('rejected'), + state_1_3 = State.objects.create(name='rejected', workflow=workflow_1, - action_word=ugettext_noop('Reject'), + action_word='Reject', css_class='danger') - state_1_4 = State.objects.create(name=ugettext_noop('not decided'), + state_1_4 = State.objects.create(name='not decided', workflow=workflow_1, - action_word=ugettext_noop('Do not decide'), + action_word='Do not decide', css_class='default') state_1_1.next_states.add(state_1_2, state_1_3, state_1_4) workflow_1.first_state = state_1_1 workflow_1.save() - workflow_2 = Workflow.objects.create(name=ugettext_noop('Complex Workflow')) - state_2_1 = State.objects.create(name=ugettext_noop('published'), + workflow_2 = Workflow.objects.create(name='Complex Workflow') + state_2_1 = State.objects.create(name='published', workflow=workflow_2, allow_support=True, allow_submitter_edit=True, dont_set_identifier=True) - state_2_2 = State.objects.create(name=ugettext_noop('permitted'), + state_2_2 = State.objects.create(name='permitted', workflow=workflow_2, - action_word=ugettext_noop('Permit'), + action_word='Permit', allow_create_poll=True, allow_submitter_edit=True, versioning=True, leave_old_version_active=True) - state_2_3 = State.objects.create(name=ugettext_noop('accepted'), + state_2_3 = State.objects.create(name='accepted', workflow=workflow_2, - action_word=ugettext_noop('Accept'), + action_word='Accept', versioning=True, css_class='success') - state_2_4 = State.objects.create(name=ugettext_noop('rejected'), + state_2_4 = State.objects.create(name='rejected', workflow=workflow_2, - action_word=ugettext_noop('Reject'), + action_word='Reject', versioning=True, css_class='danger') - state_2_5 = State.objects.create(name=ugettext_noop('withdrawed'), + state_2_5 = State.objects.create(name='withdrawed', workflow=workflow_2, - action_word=ugettext_noop('Withdraw'), + action_word='Withdraw', versioning=True, css_class='default') - state_2_6 = State.objects.create(name=ugettext_noop('adjourned'), + state_2_6 = State.objects.create(name='adjourned', workflow=workflow_2, - action_word=ugettext_noop('Adjourn'), + action_word='Adjourn', versioning=True, css_class='default') - state_2_7 = State.objects.create(name=ugettext_noop('not concerned'), + state_2_7 = State.objects.create(name='not concerned', workflow=workflow_2, - action_word=ugettext_noop('Do not concern'), + action_word='Do not concern', versioning=True, css_class='default') - state_2_8 = State.objects.create(name=ugettext_noop('commited a bill'), + state_2_8 = State.objects.create(name='commited a bill', workflow=workflow_2, - action_word=ugettext_noop('Commit a bill'), + action_word='Commit a bill', versioning=True, css_class='default') - state_2_9 = State.objects.create(name=ugettext_noop('needs review'), + state_2_9 = State.objects.create(name='needs review', workflow=workflow_2, - action_word=ugettext_noop('Needs review'), + action_word='Needs review', versioning=True, css_class='default') - state_2_10 = State.objects.create(name=ugettext_noop('rejected (not authorized)'), + state_2_10 = State.objects.create(name='rejected (not authorized)', workflow=workflow_2, - action_word=ugettext_noop('Reject (not authorized)'), + action_word='Reject (not authorized)', versioning=True, css_class='default') state_2_1.next_states.add(state_2_2, state_2_5, state_2_10) diff --git a/openslides/motions/static/js/motions/base.js b/openslides/motions/static/js/motions/base.js index 20e9ce8a1..f43455e68 100644 --- a/openslides/motions/static/js/motions/base.js +++ b/openslides/motions/static/js/motions/base.js @@ -312,5 +312,45 @@ angular.module('OpenSlidesApp.motions', ['OpenSlidesApp.users']) 'Motion', 'Category', function(Motion, Category) {} +]) + + +// Mark all motion workflow state strings for translation in JavaScript. +// (see motions/signals.py) +.config([ + 'gettext', + function (gettext) { + // workflow 1 + gettext('Simple Workflow') + gettext('submitted') + gettext('accepted') + gettext('Accept') + gettext('rejected') + gettext('Reject') + gettext('not decided') + gettext('Do not decide') + // workflow 2 + gettext('Complex Workflow') + gettext('published') + gettext('permitted') + gettext('Permit') + gettext('accepted') + gettext('Accept') + gettext('rejected') + gettext('Reject') + gettext('withdrawed') + gettext('Withdraw') + gettext('adjourned') + gettext('Adjourn') + gettext('not concerned') + gettext('Do not concern') + gettext('commited a bill') + gettext('Commit a bill') + gettext('needs review') + gettext('Needs review') + gettext('rejected (not authorized)') + gettext('Reject (not authorized)') + } ]); + }()); diff --git a/openslides/motions/static/templates/motions/slide_motion.html b/openslides/motions/static/templates/motions/slide_motion.html index b020ddc83..5fa284951 100644 --- a/openslides/motions/static/templates/motions/slide_motion.html +++ b/openslides/motions/static/templates/motions/slide_motion.html @@ -3,7 +3,7 @@