Skip to content

Commit

Permalink
Translations out of build process
Browse files Browse the repository at this point in the history
  • Loading branch information
aulemahal committed Aug 15, 2024
1 parent 8a45f0f commit 3992c98
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 97 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ jobs:
esmf=${{ env.esmf-version }}
mamba
python=${{ matrix.python-version }}
babel
tox
- name: Compile catalogs
run: |
make translate
- name: Test with tox
run: |
python -m tox -e ${{ matrix.tox-build }}
Expand All @@ -104,9 +100,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: run-Python${{ matrix.python-version }}

# - name: Compile language catalogs
# run: |
# make translate
# - name: Install esmpy
# run: |
# pip install git+https://github.com/esmf-org/esmf.git@v${{ matrix.esmf-version }}#subdirectory=src/addon/esmpy
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ jobs:
python-version: "3.x"
- name: Install packaging libraries
run: |
python -m pip install babel build setuptools wheel
python -m pip install build setuptools wheel
- name: Build a binary wheel and a source tarball
run: |
make translate
python -m build --sdist --wheel
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
3 changes: 1 addition & 2 deletions .github/workflows/tag-testpypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ jobs:
python-version: "3.x"
- name: Install packaging libraries
run: |
python -m pip install babel build setuptools wheel
python -m pip install build setuptools wheel
- name: Build a binary wheel and a source tarball
run: |
make translate
python -m build --sdist --wheel
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
Expand Down
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ docs/notebooks/samples/example*
docs/notebooks/samples/gs-weights/
!docs/notebooks/samples/tutorial/*/*/*/*/*/*/*/*.nc

# Translation stuff
*.pot

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -61,10 +64,6 @@ coverage.xml
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Internal changes
* Added pins to `xarray`, `xclim`, `h5py`, and `netcdf4`. (:pull:`414`).
* Add ``.zip`` and ``.zarr.zip`` as possible file extensions for Zarr datasets. (:pull:`426`).
* Explicitly assign coords of multiindex in `xs.unstack_fill_nan`. (:pull:`427`).
* French translations are compiled offline. A new check ensures no PR are merged with missing messages.

v0.9.1 (2024-06-04)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Once the code is implemented and translatable strings are marked as such, we nee

$ make findfrench

Then go edit ``xscen/xscen/data/fr/LC_MESSAGES/xscen.po`` with the correct French translations. Finally, running::
Then go edit ``xscen/xscen/data/fr/LC_MESSAGES/xscen.po`` with the correct French translations. Finally, run::

$ make translate

Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ recursive-include src/xscen *.py *.yml
recursive-include src/xscen/CVs *.json
recursive-include src/xscen/data/fr *.yml *.csv
recursive-include src/xscen/data *.nc
recursive-include src/xscen/data/fr/LC_MESSAGES *.mo *.po
recursive-include src/xscen/data *.mo *.po
recursive-include tests *.py
recursive-include docs conf.py Makefile make.bat *.png *.rst *.yml
recursive-include docs/locales *.mo *.po
Expand Down
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,15 @@ dev: clean ## install the package in editable mode with all development dependen
pre-commit install

findfrench: ## Extract phrases and update the French translation catalog (this doesn't translate)
python setup.py extract_messages
python setup.py update_catalog -l fr
pybabel extract -o src/xscen/data/messages.pot --omit-header --input-dirs=src/xscen/
pybabel update -l fr -D xscen -i src/xscen/data/messages.pot -d src/xscen/data/ --omit-header

translate: ## Compile the translation catalogs.
python setup.py compile_catalog
pybabel compile -f -D xscen -d src/xscen/data/

checkfrench: ## Error if the catalog could be update or if the compilation is older than the catalog.
rm -f .check_messages.pot
pybabel extract -o .check_messages.pot --omit-header --input-dirs=src/xscen/
pybabel update -l fr -D xscen -i .check_messages.pot -d src/xscen/data/ --omit-header --check
rm -f .check_messages.pot
if [ src/xscen/data/fr/LC_MESSAGES/xscen.mo -ot src/xscen/data/fr/LC_MESSAGES/xscen.po ]; then echo "Compilation is older than translations. Please compile with 'make translate'."; exit 1; fi
3 changes: 1 addition & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ dependencies:
- xclim >=0.50, <0.51
- xesmf >=0.7
- zarr
# To install from source and get translations
- babel
# To install from source
- setuptools >=65.0.0
- setuptools-scm >=8.0.0
# Opt
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
requires = [
"setuptools >=65.0.0",
"setuptools-scm >=8.0",
"babel",
"wheel"
]
build-backend = "setuptools.build_meta"
Expand Down Expand Up @@ -35,7 +34,6 @@ classifiers = [
]
dynamic = ["version"]
dependencies = [
"babel",
"cartopy >=0.23.0",
"cftime",
"cf_xarray >=0.7.6",
Expand Down Expand Up @@ -71,6 +69,7 @@ dependencies = [
dev = [
# Dev tools and testing
"pip >=23.3.0",
"babel",
"black[jupyter] ==24.4.2",
"blackdoc ==0.3.9",
"bump-my-version >=0.18.3",
Expand Down
17 changes: 0 additions & 17 deletions setup.cfg

This file was deleted.

25 changes: 0 additions & 25 deletions setup.py

This file was deleted.

39 changes: 10 additions & 29 deletions src/xscen/data/fr/LC_MESSAGES/xscen.po
Original file line number Diff line number Diff line change
@@ -1,51 +1,32 @@
# French translations for xscen.
# Copyright (C) 2023 ORGANIZATION
# This file is distributed under the same license as the xscen project.
# Équipe Xscen <[email protected]>, 2023.
#
msgid ""
msgstr ""
"Project-Id-Version: xscen 0.6.18b0\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2023-09-29 11:45-0400\n"
"PO-Revision-Date: 2023-08-15 16:48-0400\n"
"Last-Translator: Pascal Bourgault <[email protected]>\n"
"Language: fr\n"
"Language-Team: fr <[email protected]>\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.12.1\n"

#: xscen/aggregate.py:185
msgid "{window}-year mean of {attr}."
#: src/xscen/aggregate.py:435
#, fuzzy
msgid "{window}-year climatological {operation} of {attr}."
msgstr "Moyenne {window} ans de {attr}."

#: xscen/aggregate.py:319
#: src/xscen/aggregate.py:649
msgid "{attr1}: {kind} delta compared to {refhoriz}."
msgstr "{attr1}: Delta {kind} comparé à {refhoriz}."

#: xscen/diagnostics.py:501
#: src/xscen/diagnostics.py:522
msgid "Ranking of measure performance"
msgstr "Classement de performance de la mesure"

#: xscen/diagnostics.py:560
#: src/xscen/diagnostics.py:581
msgid "Fraction of improved grid cells"
msgstr "Fraction de points de grille améliorés"

#: xscen/io.py:650
#: src/xscen/io.py:761 src/xscen/io.py:769
msgid "Variable"
msgstr "Variable"

#: xscen/io.py:650
#: src/xscen/io.py:762
msgid "Description"
msgstr "Description"

#: xscen/io.py:650
#: src/xscen/io.py:765
msgid "Units"
msgstr "Unités"

#: xscen/io.py:654
#: src/xscen/io.py:770
msgid "Content"
msgstr "Contenu"
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ envlist =
py{39,310,311,312}
docs-esmpy
requires =
babel
pip >= 23.3.0
setuptools >= 65.0
opts =
--colored
--verbose

[testenv:lint]
description = Check for Code Compliance
description = Check for Code Compliance and missing french translations
skip_install = True
download = true
conda_channels =
conda_env =
deps =
babel
black[jupyter] ==24.4.2
blackdoc ==0.3.9
isort ==5.13.2
Expand All @@ -30,6 +30,7 @@ commands_pre =
pip list
commands =
make lint
make checkfrench
allowlist_externals =
make

Expand Down

0 comments on commit 3992c98

Please sign in to comment.