Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
zakird committed Feb 27, 2015
2 parents bbf6db0 + 56456c8 commit 679566c
Show file tree
Hide file tree
Showing 33 changed files with 1,751 additions and 246 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*~
chezbetty/__pycache__/*
chezbetty.egg-info/*
chezbetty/scripts/__pycache__/*
Expand All @@ -16,3 +17,4 @@ sessions/
bower_components/
*backup*.sql
RELEASE-VERSION
*.mo
69 changes: 69 additions & 0 deletions README.translation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Language Support
================

This is intended as a quick-ref for how to do common things. If you
add a new string, you have to update a few translation databases. For
more complete information, the pylons i18n docs are here:
http://docs.pylonsproject.org/docs/pyramid/en/latest/narr/i18n.html


Common Operations
-----------------

Pretty much all the interesting stuff lives in `chezbetty/locale`

**Make sure you are in the betty virtualenv before doing anything else**

### Langauge support in a fresh checkout

The translations must be compiled. An outstanding **TODO** is to add
this to an automated deploy script.

```bash
cd /chez-betty/chezbetty/locale
# foreach language
pushd es/LC_MESSAGES
msgfmt betty.po
popd
```

### Add a new language

```bash
cd /chez-betty/chezbetty/locale
# Replace 'es' (spanish) with your language code:
mkdir -p es/LC_MESSAGES
msginit -l es -o es/LC_MESSAGES/betty.po
```


### Add or Update a source string

You must first regenerate the global template.
```bash
cd /chez-betty
pot-create -c lingua.config -o chezbetty/locale/betty.pot chezbetty
```

Then you have to update the translation template for each language.
```bash
cd /chez-betty/chezbetty/locale
# Replace 'es' (spanish) with your language code:
msgmerge --update es/LC_MESSAGES/betty.po betty.pot
```

Next the actual translations for each language need to be added. This requires
editing the language-specific .po files.
```bash
vi/poedit/other_editor es/LC_MESSAGES/betty.po
```

Finally, the translations have to be compiled.
```bash
cd /chez-betty/chezbetty/locale
# foreach language
pushd es/LC_MESSAGES
msgfmt betty.po
popd
```

3 changes: 3 additions & 0 deletions chezbetty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def main(global_config, **settings):
Base.metadata.bind = engine
config = Configurator(settings=settings,
root_factory="chezbetty.models.model.RootFactory")
config.add_translation_dirs('chezbetty:locale/')

def debug(request):
if 'debugging' in request.registry.settings:
Expand Down Expand Up @@ -75,6 +76,8 @@ def debug(request):

config.add_route('index', '/')

config.add_route('lang', '/lang-{code}')

config.add_route('about', '/about')
config.add_route('shame', '/shame')

Expand Down
2 changes: 1 addition & 1 deletion chezbetty/btc.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_new_address(umid, auth_key, cb_url='{}/bitcoin/deposit'):
'{"address": {"callback_url": "%s/%s/%s", "label": "%s"}' % (cb_url, umid, auth_key, umid))

if not(obj['success']):
raise BTCException("Could not get address: %s" % res)
raise BTCException("Could not get address: %s" % umid)

return obj['address']

Expand Down
7 changes: 6 additions & 1 deletion chezbetty/datalayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,13 @@ def purchase(user, account, items):
assert(hasattr(user, "id"))
assert(len(items) > 0)

# TODO: Parameterize
discount = Decimal(0.05) if user.balance > 20.0 else None

e = event.Purchase(user)
DBSession.add(e)
DBSession.flush()
t = transaction.Purchase(e, account)
t = transaction.Purchase(e, account, discount)
DBSession.add(t)
DBSession.flush()
amount = Decimal(0.0)
Expand All @@ -134,6 +137,8 @@ def purchase(user, account, items):
item.price, item.wholesale)
DBSession.add(pli)
amount += line_amount
if discount:
amount = amount - (amount * discount)
t.update_amount(amount)
return t

Expand Down
Loading

0 comments on commit 679566c

Please sign in to comment.