Skip to content

Commit a759892

Browse files
committed
Generate translation binaries during test, release, but not when adding new locales
1 parent ea74be6 commit a759892

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ jobs:
4242
restore-keys: |
4343
${{ matrix.os }}-${{ matrix.python-version }}-v1-
4444
45+
- name: Install Linux dependencies
46+
if: startsWith(matrix.os, 'ubuntu')
47+
run: |
48+
sudo apt install gettext
49+
50+
- name: Install macOS dependencies
51+
if: startsWith(matrix.os, 'macos')
52+
run: |
53+
brew install gettext
54+
4555
- name: Install dependencies
4656
run: |
4757
python -m pip install -U pip
@@ -51,7 +61,6 @@ jobs:
5161
- name: Generate translation binaries
5262
run: |
5363
scripts/generate-translation-binaries.sh
54-
git status
5564
5665
- name: Tox tests
5766
run: |

scripts/generate-translation-binaries.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ for d in src/humanize/locale/*/; do
44
locale="$(basename $d)"
55
echo "$locale"
66
# compile to binary .mo
7-
/usr/local/opt/gettext/bin/msgfmt --check -o src/humanize/locale/$locale/LC_MESSAGES/humanize{.mo,.po}
7+
msgfmt --check -o src/humanize/locale/$locale/LC_MESSAGES/humanize{.mo,.po}
88
done

tests/test_i18n.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def test_i18n():
2020
assert humanize.ordinal(5) == "5ый"
2121
assert humanize.precisedelta(one_min_three_seconds) == "1 минута и 7 секунд"
2222

23+
except FileNotFoundError:
24+
pytest.skip("Generate .mo with scripts/generate-translation-binaries.sh")
25+
2326
finally:
2427
humanize.i18n.deactivate()
2528
assert humanize.naturaltime(three_seconds) == "3 seconds ago"
@@ -36,6 +39,9 @@ def test_intcomma():
3639
humanize.i18n.activate("fr_FR")
3740
assert humanize.intcomma(number) == "10 000 000"
3841

42+
except FileNotFoundError:
43+
pytest.skip("Generate .mo with scripts/generate-translation-binaries.sh")
44+
3945
finally:
4046
humanize.i18n.deactivate()
4147
assert humanize.intcomma(number) == "10,000,000"

0 commit comments

Comments
 (0)