Skip to content

Commit 4709a0e

Browse files
authored
feat: multilingual docs (#2522)
1 parent fe295bb commit 4709a0e

File tree

518 files changed

+396564
-126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

518 files changed

+396564
-126
lines changed

.github/CODEOWNERS

+6
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@
44
/discord/ext/testing/ @Pycord-Development/maintain-tests
55
/discord/ext/bridge/ @Pycord-Development/maintain-ext-bridge
66
/.github/ @Pycord-Development/project-leads
7+
/docs/locales/ @Pycord-Dvelopment/maintain-translations
8+
/docs/build/locales/ @Pycord-Dvelopment/maintain-translations
9+
/.github/workflows/docs-localization-download.yml @Pycord-Dvelopment/maintain-translations
10+
/.github/workflows/docs-localization-upload.yml @Pycord-Dvelopment/maintain-translations
11+
/crowdin.yml @Pycord-Dvelopment/maintain-translations
12+
/requirements/_locale.txt @Pycord-Dvelopment/maintain-translations
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Multilingual Docs Download
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
localizse:
8+
permissions: write-all
9+
name: "Localisize Docs"
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: "Install Python"
14+
uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.12"
17+
cache: "pip"
18+
cache-dependency-path: "requirements/_locale.txt"
19+
- name: "Install Dependencies"
20+
run: |
21+
python -m pip install --upgrade pip setuptools wheel
22+
pip install -r requirements/_locale.txt
23+
pip install .[speed,voice,docs]
24+
- name: "Get locales"
25+
run: |
26+
make html
27+
sphinx-build -b gettext . ./build/locales
28+
working-directory: ./docs
29+
- name: "Build locales"
30+
run:
31+
sphinx-intl update -p ./build/locales -l de -l ja -l de -l ja -l fr -l it -l
32+
hi -l ko -l pt -l es -l zh
33+
working-directory: ./docs
34+
- name: "Crowdin"
35+
uses: crowdin/github-action@v2
36+
with:
37+
upload_sources: false
38+
upload_translations: false
39+
download_translations: false
40+
download_bundle: ${{ secrets.CROWDIN_BUNDLE_ID }}
41+
localization_branch_name: l10n_master
42+
create_pull_request: true
43+
pull_request_title: "New Crowdin Translations"
44+
pull_request_body:
45+
"New Crowdin translations by [Crowdin GH
46+
Action](https://github.com/crowdin/github-action)"
47+
pull_request_base_branch_name: "master"
48+
pull_request_reviewers: "Lulalaby"
49+
config: "crowdin.yml"
50+
base_path: "."
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
54+
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Multilingual Docs Upload
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
localizse:
10+
permissions: write-all
11+
name: "Localisize Docs"
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: "Install Python"
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.12"
19+
cache: "pip"
20+
cache-dependency-path: "requirements/_locale.txt"
21+
- name: "Install Dependencies"
22+
run: |
23+
python -m pip install --upgrade pip setuptools wheel
24+
pip install -r requirements/_locale.txt
25+
pip install .[speed,voice,docs]
26+
- name: "Get locales"
27+
run: |
28+
make html
29+
sphinx-build -b gettext . ./build/locales
30+
working-directory: ./docs
31+
- name: "Build locales"
32+
run:
33+
sphinx-intl update -p ./build/locales -l de -l ja -l de -l ja -l fr -l it -l
34+
hi -l ko -l pt -l es -l zh
35+
working-directory: ./docs
36+
- name: "Crowdin"
37+
uses: crowdin/github-action@v2
38+
with:
39+
upload_sources: true
40+
upload_translations: false
41+
download_translations: false
42+
localization_branch_name: l10n_master
43+
create_pull_request: false
44+
config: "crowdin.yml"
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
48+
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
- name: Set up Python
5959
uses: actions/setup-python@v5
6060
with:
61-
python-version: "3.9"
61+
python-version: "3.12"
6262
cache: "pip"
6363
cache-dependency-path: "requirements/docs.txt"
6464
check-latest: true

.github/workflows/todo.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ jobs:
1313
SHA: ${{ github.sha }}
1414
REF: ${{ github.ref }}
1515
COMMENT_ON_ISSUES: true
16+
EXCLUDE_PATTERN: "\\.(doctree|doctrees|pickle)$"

.github/workflows/version-updates.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ permissions:
88
jobs:
99
auto-merge:
1010
runs-on: ubuntu-latest
11-
if: ${{ github.actor == 'dependabot[bot]' }}
11+
if: ${{ github.actor == 'dependabot[bot]' || github.actor == 'crowdin-bot' }}
1212
steps:
1313
- run: gh pr review --approve "$PR_URL"
1414
env:

.gitignore

+20-15
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ __pycache__/
88

99
# Distribution / packaging
1010
.Python
11-
build/
11+
./build/
12+
./_build/
1213
develop-eggs/
1314
dist/
1415
downloads/
@@ -51,10 +52,6 @@ coverage.xml
5152
.pytest_cache/
5253
cover/
5354

54-
# Translations
55-
*.mo
56-
*.pot
57-
5855
# Django stuff:
5956
*.log
6057
local_settings.py
@@ -165,17 +162,16 @@ cython_debug/
165162
*.egg-info
166163
.venv/
167164
docs/_build
168-
docs/crowdin.py
169165
*.buildinfo
170-
*.mp3
171-
*.m4a
172-
*.wav
173-
*.mp4
174-
*.ogg
175-
*.pcm
176-
*.png
177-
*.jpg
178-
*.flac
166+
!*.mp3
167+
!*.m4a
168+
!*.wav
169+
!*.mp4
170+
!*.ogg
171+
!*.pcm
172+
!*.png
173+
!*.jpg
174+
!*.flac
179175
.vs/
180176
.DS_Store
181177
__pycache__
@@ -186,3 +182,12 @@ node_modules/*
186182

187183
# changelog is autogenerated from CHANGELOG.md
188184
docs/changelog.md
185+
186+
# Translations
187+
docs/build/html
188+
docs/build/doctrees
189+
!docs/build/locales/*
190+
*.mo
191+
!docs/locales/*
192+
/build/
193+
/vscode/

.pre-commit-config.yaml

+9-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ repos:
77
rev: v4.6.0
88
hooks:
99
- id: trailing-whitespace
10+
exclude: \.(po|pot)$
1011
- id: end-of-file-fixer
12+
exclude: \.(po|pot)$
1113
- repo: https://github.com/PyCQA/autoflake
1214
rev: v2.3.1
1315
hooks:
@@ -19,19 +21,21 @@ repos:
1921
# - --remove-duplicate-keys
2022
# - --remove-unused-variables
2123
- repo: https://github.com/asottile/pyupgrade
22-
rev: v3.16.0
24+
rev: v3.17.0
2325
hooks:
2426
- id: pyupgrade
25-
args: [--py38-plus]
27+
exclude: \.(po|pot)$
2628
- repo: https://github.com/PyCQA/isort
2729
rev: 5.13.2
2830
hooks:
2931
- id: isort
32+
exclude: \.(po|pot)$
3033
- repo: https://github.com/psf/black
31-
rev: 24.4.2
34+
rev: 24.8.0
3235
hooks:
3336
- id: black
3437
args: [--safe, --quiet]
38+
exclude: \.(po|pot)$
3539
- repo: https://github.com/Pierre-Sassoulas/black-disable-checker
3640
rev: v1.1.3
3741
hooks:
@@ -81,10 +85,12 @@ repos:
8185
hooks:
8286
- id: prettier
8387
args: [--prose-wrap=always, --print-width=88]
88+
exclude: \.(po|pot)$
8489
- repo: https://github.com/DanielNoord/pydocstringformatter
8590
rev: v0.7.3
8691
hooks:
8792
- id: pydocstringformatter
93+
exclude: \.(po|pot)$
8894
args:
8995
[
9096
--style=numpydoc,

.readthedocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ formats: []
44
build:
55
os: ubuntu-22.04
66
tools:
7-
python: "3.9"
7+
python: "3.12"
88

99
sphinx:
1010
configuration: docs/conf.py

README.rst

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Pycord
1616
.. image:: https://img.shields.io/github/v/release/Pycord-Development/pycord?include_prereleases&label=Latest%20Release&logo=github&sort=semver&style=for-the-badge&logoColor=white
1717
:target: https://github.com/Pycord-Development/pycord/releases
1818
:alt: Latest release
19+
.. image:: https://badges.crowdin.net/badge/dark/crowdin-on-light.png
20+
:target: https://crowdin.com/?utm_source=badge&utm_medium=referral&utm_campaign=badge-add-on
21+
:alt: Crowdin | Agile localization for tech companies
1922

2023
A fork of discord.py. Pycord is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Python.
2124

@@ -141,3 +144,9 @@ Useful Links
141144
- `Learn how to create Discord bots with Pycord <https://guide.pycord.dev>`_
142145
- `Our Official Discord Server <https://pycord.dev/discord>`_
143146
- `Official Discord Developers Server <https://discord.gg/discord-developers>`_
147+
148+
Translations
149+
------------
150+
151+
.. image:: https://badges.awesome-crowdin.com/translation-200034237-5.png
152+
:alt: Translation Status

crowdin.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
base_path: "docs/build/locales"
2+
base_url: "https://pycord.crowdin.com"
3+
4+
preserve_hierarchy: true
5+
6+
commit_message: "docs: Update translations"
7+
8+
export_languages: ["de", "ja", "fr", "it", "hi", "ko", "pt-BR", "es-ES", "zh-CN"]
9+
10+
bundles:
11+
- 4
12+
13+
files:
14+
[
15+
{
16+
source: "**/*.pot",
17+
translation: "/docs/locales/%two_letters_code%/LC_MESSAGES/%original_path%/%file_name%.po",
18+
},
19+
]

discord/audit_logs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class AuditLogDiff:
213213
def __len__(self) -> int:
214214
return len(self.__dict__)
215215

216-
def __iter__(self) -> Generator[tuple[str, Any], None, None]:
216+
def __iter__(self) -> Generator[tuple[str, Any]]:
217217
yield from self.__dict__.items()
218218

219219
def __repr__(self) -> str:

discord/bot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ def inner(cls: type[SlashCommandGroup]) -> SlashCommandGroup:
10511051

10521052
slash_group = group
10531053

1054-
def walk_application_commands(self) -> Generator[ApplicationCommand, None, None]:
1054+
def walk_application_commands(self) -> Generator[ApplicationCommand]:
10551055
"""An iterator that recursively walks through all application commands and subcommands.
10561056
10571057
Yields

discord/client.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ def get_poll(self, id: int, /) -> Poll | None:
10411041
"""
10421042
return self._connection.get_poll(id)
10431043

1044-
def get_all_channels(self) -> Generator[GuildChannel, None, None]:
1044+
def get_all_channels(self) -> Generator[GuildChannel]:
10451045
"""A generator that retrieves every :class:`.abc.GuildChannel` the client can 'access'.
10461046
10471047
This is equivalent to: ::
@@ -1065,7 +1065,7 @@ def get_all_channels(self) -> Generator[GuildChannel, None, None]:
10651065
for guild in self.guilds:
10661066
yield from guild.channels
10671067

1068-
def get_all_members(self) -> Generator[Member, None, None]:
1068+
def get_all_members(self) -> Generator[Member]:
10691069
"""Returns a generator with every :class:`.Member` the client can see.
10701070
10711071
This is equivalent to: ::

discord/cog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def description(self) -> str:
346346
def description(self, description: str) -> None:
347347
self.__cog_description__ = description
348348

349-
def walk_commands(self) -> Generator[ApplicationCommand, None, None]:
349+
def walk_commands(self) -> Generator[ApplicationCommand]:
350350
"""An iterator that recursively walks through this cog's commands and subcommands.
351351
352352
Yields

discord/commands/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,7 @@ async def call_after_hooks(self, ctx: ApplicationContext) -> None:
15131513
else:
15141514
await self._after_invoke(ctx) # type: ignore
15151515

1516-
def walk_commands(self) -> Generator[SlashCommand | SlashCommandGroup, None, None]:
1516+
def walk_commands(self) -> Generator[SlashCommand | SlashCommandGroup]:
15171517
"""An iterator that recursively walks through all slash commands and groups in this group.
15181518
15191519
Yields

discord/ext/commands/cog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __new__(cls: type[CogT], *args: Any, **kwargs: Any) -> CogT:
5050
# To do this, we need to interfere with the Cog creation process.
5151
return super().__new__(cls)
5252

53-
def walk_commands(self) -> Generator[Command, None, None]:
53+
def walk_commands(self) -> Generator[Command]:
5454
"""An iterator that recursively walks through this cog's commands and subcommands.
5555
5656
Yields

discord/ext/commands/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ def remove_command(self, name: str) -> Command[CogT, Any, Any] | None:
13261326
self.prefixed_commands[alias] = cmd
13271327
return command
13281328

1329-
def walk_commands(self) -> Generator[Command[CogT, Any, Any], None, None]:
1329+
def walk_commands(self) -> Generator[Command[CogT, Any, Any]]:
13301330
"""An iterator that recursively walks through all commands and subcommands.
13311331
13321332
.. versionchanged:: 1.4

discord/oggparse.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(self, stream: IO[bytes]) -> None:
7474
except Exception:
7575
raise OggError("bad data stream") from None
7676

77-
def iter_packets(self) -> Generator[tuple[bytes, bool], None, None]:
77+
def iter_packets(self) -> Generator[tuple[bytes, bool]]:
7878
packetlen = offset = 0
7979
partial = True
8080

@@ -106,13 +106,13 @@ def _next_page(self) -> OggPage | None:
106106
else:
107107
raise OggError("invalid header magic")
108108

109-
def _iter_pages(self) -> Generator[OggPage, None, None]:
109+
def _iter_pages(self) -> Generator[OggPage]:
110110
page = self._next_page()
111111
while page:
112112
yield page
113113
page = self._next_page()
114114

115-
def iter_packets(self) -> Generator[bytes, None, None]:
115+
def iter_packets(self) -> Generator[bytes]:
116116
partial = b""
117117
for page in self._iter_pages():
118118
for data, complete in page.iter_packets():

0 commit comments

Comments
 (0)