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

Take translation out of the build process #443

Merged
merged 7 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 0 additions & 1 deletion .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ on:
- environment-dev.yml
- environment.yml
- pyproject.toml
- setup.py
- src/xscen/__init__.py
- templates
- tests/*.py
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ on:
- CHANGELOG.rst
- README.rst
- pyproject.toml
- setup.cfg
- setup.py
- xscen/__init__.py
pull_request:

Expand Down Expand Up @@ -91,11 +89,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 +98,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
2 changes: 0 additions & 2 deletions .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ on:
- CHANGELOG.rst
- README.rst
- pyproject.toml
- setup.cfg
- setup.py
- xscen/__init__.py
schedule:
- cron: "0 0 * * *" # Daily “At 00:00” UTC
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
2 changes: 0 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ repos:
rev: v4.6.0
hooks:
- id: trailing-whitespace
exclude: setup.cfg
- id: end-of-file-fixer
exclude: setup.cfg
- id: debug-statements
- id: mixed-line-ending
- id: check-json
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. (:issue:`342`, :pull: `443`).
aulemahal marked this conversation as resolved.
Show resolved Hide resolved

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
4 changes: 1 addition & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ include LICENSE
include Makefile
include README.rst
include pyproject.toml
include setup.cfg
include setup.py
include .zenodo.json

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
2 changes: 1 addition & 1 deletion environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
dependencies:
- python >=3.9,<3.13
# Don't forget to sync changes between environment.yml, environment-dev.yml, and setup.py!
# Don't forget to sync changes between environment.yml, environment-dev.yml, and pyproject.toml!
# Also consider updating the list in xs.utils.show_versions if you add a new package.
# Main packages
- cartopy >=0.23.0
Expand Down
5 changes: 2 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
dependencies:
- python >=3.9,<3.13
# Don't forget to sync changes between environment.yml, environment-dev.yml, and setup.py!
# Don't forget to sync changes between environment.yml, environment-dev.yml, and pyproject.toml!
# Also consider updating the list in xs.utils.show_versions if you add a new package.
# Main packages
- cartopy >=0.23.0
Expand Down 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
5 changes: 1 addition & 4 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 Expand Up @@ -286,8 +285,6 @@ include = ["xscen"]
# "docs/notebooks/samples/*.yml",
# "environment.yml",
# "environment-dev.yml",
# "setup.cfg",
# "setup.py",
# "src/xscen/**/*.py",
# "src/xscen/**/*.yml",
# "src/xscen/CVs/*.json",
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.

Binary file added src/xscen/data/fr/LC_MESSAGES/xscen.mo
Binary file not shown.
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
Loading