-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #362 from OpenDataServices/translations
Translate strings that appear in the cove web interface
- Loading branch information
Showing
14 changed files
with
737 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
*.egg-info | ||
*.pyc | ||
*.swp | ||
*.mo | ||
.vscode | ||
.cache | ||
.coverage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[main] | ||
host = https://www.transifex.com | ||
|
||
[cove-common.flatten-tool] | ||
file_filter = flattentool/locale/<lang>/LC_MESSAGES/flatten-tool.po | ||
source_file = flattentool/locale/en/LC_MESSAGES/flatten-tool.po | ||
source_lang = en | ||
type = PO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Extraction from Python source files | ||
[python: **.py] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import gettext | ||
from pathlib import Path | ||
|
||
domain = "flatten-tool" | ||
locale_dir = str(Path(__file__).parent / "locale") | ||
|
||
try: | ||
# If we can get the language from Django use that | ||
from django.core.exceptions import ImproperlyConfigured | ||
from django.utils.translation import get_language | ||
|
||
try: | ||
get_language() | ||
except ImproperlyConfigured: | ||
raise ImportError | ||
|
||
# We set up the translations ourselves, instead of using Django's gettext | ||
# function, so that we can have a custom domain and locale directory. | ||
translations = {} | ||
translations["en"] = gettext.translation(domain, locale_dir, languages=["en"]) | ||
translations["es"] = gettext.translation(domain, locale_dir, languages=["es"]) | ||
|
||
def _(text): | ||
lang = get_language() | ||
if lang not in translations: | ||
lang = "en" | ||
return translations[lang].gettext(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 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.