Explorar el Código

chore(i18n): migrate from POEditor to Weblate (#170)

tags/v0.10.0
Jérôme Deuchnord hace 4 años
committed by GitHub
padre
commit
0d9e7e2f0a
No se encontró ninguna clave conocida en la base de datos para esta firma ID de clave GPG: 4AEE18F83AFDEB23
Se han modificado 6 ficheros con 17 adiciones y 85 borrados
  1. +2
    -21
      .github/workflows/release.yml
  2. +1
    -2
      .gitignore
  3. +0
    -52
      .scripts/build/getlangs.py
  4. +4
    -4
      CONTRIBUTING.md
  5. +2
    -5
      Makefile
  6. +8
    -1
      README.md

+ 2
- 21
.github/workflows/release.yml Ver fichero

@@ -24,12 +24,6 @@ jobs:
changelog="${changelog//$'\n'/'%0A'}" changelog="${changelog//$'\n'/'%0A'}"
changelog="${changelog//$'\r'/'%0D'}" changelog="${changelog//$'\r'/'%0D'}"
echo "::set-output name=changelog::$changelog" echo "::set-output name=changelog::$changelog"
- name: Build locales
env:
POEDITOR_API_ACCESS: ${{ secrets.POEDITOR_API_ACCESS }}
run: |
make POEDITOR_API_ACCESS="${POEDITOR_API_ACCESS}" i18n
tar cf locales.tar.gz kosmorrolib/locales
- name: Create release - name: Create release
id: create_release id: create_release
uses: actions/create-release@v1 uses: actions/create-release@v1
@@ -42,19 +36,8 @@ jobs:
prerelease: false prerelease: false
body: | body: |
${{ steps.prepare_release.outputs.changelog }} ${{ steps.prepare_release.outputs.changelog }}
- name: Upload locales
id: upload-locales
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./locales.tar.gz
asset_name: locales.tar.gz
asset_content_type: application/x-tar



pip:
pipy:
name: Release to PyPI name: Release to PyPI
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -76,9 +59,7 @@ jobs:
env: env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
POEDITOR_API_ACCESS: ${{ secrets.POEDITOR_API_ACCESS }}
POEDITOR_PROJECT_ID: 306433 POEDITOR_PROJECT_ID: 306433
run: | run: |
make POEDITOR_API_ACCESS="${POEDITOR_API_ACCESS}" POEDITOR_PROJECT_ID="306433" build
make i18n build
twine upload dist/* twine upload dist/*


+ 1
- 2
.gitignore Ver fichero

@@ -12,6 +12,5 @@ coverage.xml
/manpage/* /manpage/*
!/manpage/*.md !/manpage/*.md


# Translation files are taken care on https://poeditor.com/join/project/GXuhLpdaoh
# Compiled internationalization files
*.mo *.mo
*.po

+ 0
- 52
.scripts/build/getlangs.py Ver fichero

@@ -1,52 +0,0 @@
#!/usr/bin/env python3

# This script's purpose is to retrieve the translations from POEditor (https://poeditor.com).
# It is mainly used in the release process.
# (c) Jérôme Deuchnord - MIT License

import os
import requests

POEDITOR_URL = 'https://api.poeditor.com/v2'
API_TOKEN = os.environ['POEDITOR_API_ACCESS']
PROJECT_ID = os.environ['POEDITOR_PROJECT_ID']

languages = requests.post('%s/languages/list' % POEDITOR_URL,
data={'api_token': API_TOKEN,
'id': PROJECT_ID})

json = languages.json()

if languages.status_code != 200:
raise AssertionError(json['response']['message'])

for language in json['result']['languages']:
if language['percentage'] < 100:
# Ignore unfinished translations
continue

print('Importing finished translation for %s... ' % language['name'], end='')

translations = requests.post('%s/projects/export' % POEDITOR_URL,
data={'api_token': API_TOKEN,
'id': PROJECT_ID,
'language': language['code'],
'type': 'po'})

if translations.status_code != 200:
print('Failed!')
raise AssertionError(translations.json()['response']['message'])

translations = requests.get(translations.json()['result']['url'])

if translations.status_code != 200:
print('Failed!')
raise AssertionError('URL given by the API returned a %d status code' % translations.status_code)

os.makedirs('kosmorrolib/locales/%s/LC_MESSAGES' % language['code'], exist_ok=True)

with open('kosmorrolib/locales/%s/LC_MESSAGES/messages.po' % language['code'], 'w') as file:
file.write(translations.text)

print('OK')


+ 4
- 4
CONTRIBUTING.md Ver fichero

@@ -17,7 +17,7 @@ First, please check someone didn't suggest your next revolution in the _Issues_


## Translating ## Translating


If you speak another language than English, another nice way to enhance Kosmorro is to translate its messages. The recommended way to begin translating Kosmorro is to [join the POEditor team](https://poeditor.com/join/project/GXuhLpdaoh).
If you speak another language than English, another nice way to enhance Kosmorro is to translate its messages. The recommended way to begin translating Kosmorro is to [join the Weblate project](https://hosted.weblate.org/engage/kosmorro/).


## Writing code ## Writing code


@@ -44,7 +44,7 @@ The messages file contains all the messages Kosmorro can display, in order to ma
When you add a new string that will be displayed to the end user, please pass it to the `_()` function made available in the `kosmorrolib.i18n` package, for instance: When you add a new string that will be displayed to the end user, please pass it to the `_()` function made available in the `kosmorrolib.i18n` package, for instance:


```python ```python
# Dont:
# Don't:
print('Note: All the hours are given in UTC.') print('Note: All the hours are given in UTC.')


# Do: # Do:
@@ -57,10 +57,10 @@ This will allow Python's internationalization tool to translate the string in an
Once you have done your work, please remember to tell [Babel](http://babel.pocoo.org) to extract the new strings: Once you have done your work, please remember to tell [Babel](http://babel.pocoo.org) to extract the new strings:


```console ```console
$ pipenv run python setup.py extract_messages --output-file=kosmorrolib/locales/messages.pot
$ make messages
``` ```


> If the `setup.py` script tells you that the `extract_messages` command does not exist, then run `kosmorro sync` to ensure all the dev dependencies are installed and try again.
> If the `setup.py` script tells you that the `extract_messages` command does not exist, then run `pipenv sync` to ensure all the dev dependencies are installed and try again.


Note that if you forget to update the messages file, the CI will fail. Note that if you forget to update the messages file, the CI will fail.




+ 2
- 5
Makefile Ver fichero

@@ -8,7 +8,7 @@ test:
unset KOSMORRO_TIMEZONE; \ unset KOSMORRO_TIMEZONE; \
LANG=C pipenv run python3 -m coverage run -m unittest test LANG=C pipenv run python3 -m coverage run -m unittest test


build: i18n manpages
build: manpages
python3 setup.py sdist bdist_wheel python3 setup.py sdist bdist_wheel


messages: messages:
@@ -19,10 +19,7 @@ manpages:
ronn --roff manpage/kosmorro.7.md ronn --roff manpage/kosmorro.7.md


i18n: i18n:
if [ "$$POEDITOR_API_ACCESS" != "" ]; then \
python3 .scripts/build/getlangs.py; \
python3 setup.py compile_catalog; \
fi
python3 setup.py compile_catalog; \


env: env:
@if [[ "$$RELEASE_NUMBER" == "" ]]; \ @if [[ "$$RELEASE_NUMBER" == "" ]]; \


+ 8
- 1
README.md Ver fichero

@@ -1,5 +1,5 @@
# ![Kosmorro](kosmorrolib/assets/png/kosmorro-logo.png) # ![Kosmorro](kosmorrolib/assets/png/kosmorro-logo.png)
[![Coverage Status](https://coveralls.io/repos/github/Kosmorro/kosmorro/badge.svg?branch=master)](https://coveralls.io/github/Kosmorro/kosmorro?branch=master) [![Version on PyPI](https://img.shields.io/pypi/v/kosmorro)](https://pypi.org/project/kosmorro) [![Discord](https://img.shields.io/discord/650237632533757965?logo=discord&label=%23kosmorro)](https://discord.gg/TVX4MSKGaa) ![Docker Pulls](https://img.shields.io/docker/pulls/kosmorro/kosmorro)
[![Coverage Status](https://coveralls.io/repos/github/Kosmorro/kosmorro/badge.svg?branch=master)](https://coveralls.io/github/Kosmorro/kosmorro?branch=master) [![Version on PyPI](https://img.shields.io/pypi/v/kosmorro)](https://pypi.org/project/kosmorro) [![Discord](https://img.shields.io/discord/650237632533757965?logo=discord&label=%23kosmorro)](https://discord.gg/TVX4MSKGaa) ![Docker Pulls](https://img.shields.io/docker/pulls/kosmorro/kosmorro) [![Help translating Kosmorro!](https://hosted.weblate.org/widgets/kosmorro/-/cli/svg-badge.svg)](https://hosted.weblate.org/engage/kosmorro/)


A program that calculates your astronomical ephemerides! A program that calculates your astronomical ephemerides!


@@ -98,3 +98,10 @@ Before you use this feature, make sure you have installed a LaTeX distribution:
- with Brew: `brew install basictex` - with Brew: `brew install basictex`


These dependencies are not installed by default, because they take a lot of place and are not necessary if you are not interested in generating PDF files. These dependencies are not installed by default, because they take a lot of place and are not necessary if you are not interested in generating PDF files.

## Help translating Kosmorro!

Kosmorro is translated on [Weblate](https://hosted.weblate.org/engage/kosmorro/), a popular free platform for crowd-sourced internationalization.
If you speak a language that is not supported yet, feel free to contribute!

![Translation state per language](https://hosted.weblate.org/widgets/kosmorro/-/cli/multi-auto.svg)

Cargando…
Cancelar
Guardar