Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: standardize make extract_translations #100

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ package-lock.json
sdk/
venv/
.idea/

# Translations
sql_grader/conf/locale/*/LC_MESSAGES/*
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ ifeq ($(strip $(po_files)),)
endif
mo_files := $(patsubst %.po,%.mo,$(po_files))

WORKING_DIR := sql_grader
EXTRACT_DIR := $(WORKING_DIR)/conf/locale/en/LC_MESSAGES
EXTRACTED_DJANGO_PARTIAL := $(EXTRACT_DIR)/django-partial.po
EXTRACTED_DJANGOJS_PARTIAL := $(EXTRACT_DIR)/djangojs-partial.po
EXTRACTED_DJANGO := $(EXTRACT_DIR)/django.po


.PHONY: help
help: ## This.
@perl -ne 'print if /^[a-zA-Z_-]+:.*## .*$$/' $(MAKEFILE_LIST) \
Expand Down Expand Up @@ -136,3 +143,14 @@ docker_shell:
docker_static: ; make build_docker; $(run-in-docker) ## Compile static assets in docker container
docker_translations: ; make build_docker; $(run-in-docker) ## Update translation files in docker container
docker_test: ; make build_docker; $(run-in-docker) ## Run tests in docker container

extract_translations: ## extract strings to be translated, outputting .po files
cd $(WORKING_DIR) && i18n_tool extract
mv $(EXTRACTED_DJANGO_PARTIAL) $(EXTRACTED_DJANGO)
# Safely concatenate djangojs if it exists
if test -f $(EXTRACTED_DJANGOJS_PARTIAL); then \
msgcat $(EXTRACTED_DJANGO) $(EXTRACTED_DJANGOJS_PARTIAL) -o $(EXTRACTED_DJANGO) && \
rm $(EXTRACTED_DJANGOJS_PARTIAL); \
fi
sed -i'' -e 's/nplurals=INTEGER/nplurals=2/' $(EXTRACTED_DJANGO)
sed -i'' -e 's/plural=EXPRESSION/plural=\(n != 1\)/' $(EXTRACTED_DJANGO)
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from setuptools import find_packages, setup

README = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()


def package_data(pkg, roots):
"""
Expand Down Expand Up @@ -96,6 +98,8 @@ def is_requirement(line):
version='0.3.1',
description='SQL Grader XBlock', # TODO: write a better description.
license='AGPLv3',
long_description=README,
long_description_content_type='text/x-rst',
packages=find_packages(exclude=('sql_grader.tests')),
install_requires=load_requirements('requirements/base.in'),
entry_points={
Expand All @@ -110,6 +114,7 @@ def is_requirement(line):
'scenarios/*.xml',
'static',
'templates/*.html',
'translations',
]
),
classifiers=[
Expand Down
4 changes: 4 additions & 0 deletions sql_grader/conf/locale/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Configuration for i18n workflow.

locales:
- en # English - Source Language
1 change: 1 addition & 0 deletions sql_grader/translations