Skip to content

Commit

Permalink
Added support for i18n
Browse files Browse the repository at this point in the history
The project now supports i18n with translations from Transifex.
  • Loading branch information
clintonb committed Mar 6, 2018
1 parent f4b10e8 commit 4d5b3b3
Show file tree
Hide file tree
Showing 14 changed files with 742 additions and 59 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ python:
- "3.5"
- "3.6"

matrix:
include:
- python: 3.6
env: TOXENV=i18n

install:
- pip install tox tox-travis

Expand Down
9 changes: 9 additions & 0 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[main]
host = https://www.transifex.com

[django-waffle.django-po]
file_filter = waffle/locale/<lang>/LC_MESSAGES/django.po
minimum_perc = 0
source_file = waffle/locale/en_US/LC_MESSAGES/django.po
source_lang = en
type = PO
1 change: 1 addition & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ To be mergable, patches must:
- add tests for new code (bug fixes should include regression tests, new
features should have relevant tests),
- not introduce any new flake8_ errors (run ``./run.sh lint``),
- include updated source translations (run ``./run.sh makemessages`` and ``./run.sh compilemessages``),
- document any new features, and
- have a `good commit message`_.

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include LICENSE
include README.rst
include waffle/templates/waffle/waffle.js
recursive-include waffle/locale *.mo
6 changes: 6 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ case "$CMD" in
django-admin.py shell $@ ;;
"makemigrations" )
django-admin.py makemigrations waffle $@ ;;
"makemessages" )
export DJANGO_SETTINGS_MODULE= && cd waffle && django-admin.py makemessages && cd - ;;
"compilemessages" )
export DJANGO_SETTINGS_MODULE= && cd waffle && django-admin.py compilemessages && cd - ;;
"find_uncommitted_translations" )
git diff --exit-code -G "^(msgid|msgstr)" || (echo "Please run ./run.sh makemessages and commit the updated django.po file." && false) ;;
* )
usage ;;
esac
6 changes: 6 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ deps =
-rtravis.txt
commands =
./run.sh test

[testenv:i18n]
commands =
./run.sh makemessages
./run.sh compilemessages
./run.sh find_uncommitted_translations
2 changes: 2 additions & 0 deletions travis.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
mock==1.3.0
Jinja2>=2.7.1
django-jinja>=2.1,<3

transifex-client
7 changes: 4 additions & 3 deletions waffle/admin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from __future__ import unicode_literals

from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from waffle.models import Flag, Sample, Switch


class BaseAdmin(admin.ModelAdmin):
search_fields = ('name', 'note')

def get_actions(self, request):
actions = super(BaseAdmin, self).get_actions(request)
if 'delete_selected' in actions:
Expand Down Expand Up @@ -61,8 +62,8 @@ def disable_switches(ma, request, qs):
switch.save()


enable_switches.short_description = 'Enable the selected switches.'
disable_switches.short_description = 'Disable the selected switches.'
enable_switches.short_description = _('Enable the selected switches.')
disable_switches.short_description = _('Disable the selected switches.')


class SwitchAdmin(BaseAdmin):
Expand Down
Binary file added waffle/locale/en_US/LC_MESSAGES/django.mo
Binary file not shown.
206 changes: 206 additions & 0 deletions waffle/locale/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-03-05 20:22-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: admin.py:65
msgid "Enable the selected switches."
msgstr ""

#: admin.py:66
msgid "Disable the selected switches."
msgstr ""

#: models.py:124 models.py:349 models.py:400
msgid "The human/computer readable name."
msgstr ""

#: models.py:125 models.py:350 models.py:401
msgid "Name"
msgstr ""

#: models.py:130
msgid ""
"Flip this flag on (Yes) or off (No) for everyone, overriding all other "
"settings. Leave as Unknown to use normally."
msgstr ""

#: models.py:132
msgid "Everyone"
msgstr ""

#: models.py:139
msgid ""
"A number between 0.0 and 99.9 to indicate a percentage of users for whom "
"this flag will be active."
msgstr ""

#: models.py:141 models.py:408
msgid "Percent"
msgstr ""

#: models.py:145
msgid "Allow this flag to be set for a session for user testing"
msgstr ""

#: models.py:146
msgid "Testing"
msgstr ""

#: models.py:150
msgid "Flag always active for superusers?"
msgstr ""

#: models.py:151
msgid "Superusers"
msgstr ""

#: models.py:155
msgid "Flag always active for staff?"
msgstr ""

#: models.py:156
msgid "Staff"
msgstr ""

#: models.py:160
msgid "Flag always active for authenticated users?"
msgstr ""

#: models.py:161
msgid "Authenticated"
msgstr ""

#: models.py:166
msgid ""
"Activate this flag for users with one of these languages (comma-separated "
"list)"
msgstr ""

#: models.py:167
msgid "Languages"
msgstr ""

#: models.py:172
msgid "Activate this flag for these user groups."
msgstr ""

#: models.py:173
msgid "Groups"
msgstr ""

#: models.py:178
msgid "Activate this flag for these users."
msgstr ""

#: models.py:179
msgid "Users"
msgstr ""

#: models.py:183
msgid "Activate roll-out mode?"
msgstr ""

#: models.py:184
msgid "Rollout"
msgstr ""

#: models.py:188
msgid "Note where this Flag is used."
msgstr ""

#: models.py:189 models.py:360 models.py:413
msgid "Note"
msgstr ""

#: models.py:194
msgid "Date when this Flag was created."
msgstr ""

#: models.py:195 models.py:366 models.py:419
msgid "Created"
msgstr ""

#: models.py:199
msgid "Date when this Flag was last modified."
msgstr ""

#: models.py:200 models.py:371 models.py:424
msgid "Modified"
msgstr ""

#: models.py:209
msgid "Flag"
msgstr ""

#: models.py:210
msgid "Flags"
msgstr ""

#: models.py:354
msgid "Is this switch active?"
msgstr ""

#: models.py:355
msgid "Active"
msgstr ""

#: models.py:359
msgid "Note where this Switch is used."
msgstr ""

#: models.py:365
msgid "Date when this Switch was created."
msgstr ""

#: models.py:370
msgid "Date when this Switch was last modified."
msgstr ""

#: models.py:380
msgid "Switch"
msgstr ""

#: models.py:381
msgid "Switches"
msgstr ""

#: models.py:406
msgid ""
"A number between 0.0 and 100.0 to indicate a percentage of the time this "
"sample will be active."
msgstr ""

#: models.py:412
msgid "Note where this Sample is used."
msgstr ""

#: models.py:418
msgid "Date when this Sample was created."
msgstr ""

#: models.py:423
msgid "Date when this Sample was last modified."
msgstr ""

#: models.py:433
msgid "Sample"
msgstr ""

#: models.py:434
msgid "Samples"
msgstr ""
Binary file added waffle/locale/ru/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 4d5b3b3

Please sign in to comment.