Skip to content

Commit

Permalink
Merge pull request #364 from OpenDataServices/fix-mo-fail
Browse files Browse the repository at this point in the history
i18n: Don't fail if compiled translation files (.mo) don't exist
  • Loading branch information
Bjwebb authored Oct 21, 2020
2 parents 2667a7a + 561da04 commit ab4e63e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [0.15.1] - 2020-10-21

### Fixed

- Don't fail if compiled translation files (.mo) don't exist

## [0.15.0] - 2020-10-19

### Added
Expand Down
12 changes: 8 additions & 4 deletions flattentool/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def _(text):


except ImportError:
# If there's no Django, call gettext.translation without a languages array,
# and it will pick one based on the environment variables.
t = gettext.translation(domain, locale_dir)
_ = t.gettext
try:
# If there's no Django, call gettext.translation without a languages array,
# and it will pick one based on the environment variables.
t = gettext.translation(domain, locale_dir)
_ = t.gettext
except FileNotFoundError:
# If .mo files don't exist, pass a fake gettext function instead
_ = lambda x: x
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def run(self):

setup(
name="flattentool",
version="0.15.0",
version="0.15.1",
author="Open Data Services",
author_email="code@opendataservices.coop",
packages=["flattentool"],
Expand Down

0 comments on commit ab4e63e

Please sign in to comment.