Skip to content

Commit

Permalink
Merge pull request #100 from Zeit-Labs/shadinaif/FC-0012-OEP-58
Browse files Browse the repository at this point in the history
feat: standardize make extract_translations
  • Loading branch information
brian-smith-tcril authored May 30, 2023
2 parents fe55867 + c49ed13 commit 4a94650
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
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

0 comments on commit 4a94650

Please sign in to comment.