Skip to content

Add Parts of Simplified Chinese Translation for Documents #460

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ __pycache__/
.venv
*.egg
*.egg-info/
*.mo
*.py[cod]
*.swp
*~
Expand Down
112 changes: 87 additions & 25 deletions bookshelf/commands/docs.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,116 @@
import shutil
import subprocess
from contextlib import suppress

import click

from bookshelf.definitions import DOC_DIR, EXAMPLES_DIR
from bookshelf.logger import log_step


@click.group()
def docs() -> None:
"""Documentation-related commands."""
"""Documentation-related commands: build, watch, and manage locales."""


@docs.command()
@click.argument("output", required=False)
@click.option("--builder", default="html", help="The builder to use for Sphinx")
def build(output: str | None = None, builder: str = "html") -> None:
@click.option("--lang", default=None, help="The language to use for the documentation")
def build(
output: str | None = None,
builder: str = "html",
lang: str | None = None,
) -> None:
"""Build static HTML documentation."""
sphinx = shutil.which("sphinx-build")
if not sphinx:
error_msg = "The 'sphinx-build' command was not found."
raise FileNotFoundError(error_msg)

subprocess.run([
sphinx,
".",
"-b",
builder,
output if output else "_build",
], check=True, cwd=DOC_DIR)
with log_step("🔨 Building documentation…"):
subprocess.run([
command("sphinx-build"),
".",
"-b",
builder,
"-D",
f"language={lang or 'en'}",
output if output else "_build",
], check=True, cwd=DOC_DIR)


@docs.command()
@click.argument("output", required=False)
@click.option("--builder", default="html", help="The builder to use for Sphinx")
def watch(output: str | None = None, builder: str = "html") -> None:
@click.option("--lang", default=None, help="The language to use for the documentation")
def watch(
output: str | None = None,
builder: str = "html",
lang: str | None = None,
) -> None:
"""Build and serve live documentation."""
try:
sphinx = shutil.which("sphinx-autobuild")
if not sphinx:
error_msg = "The 'sphinx-autobuild' command was not found."
raise FileNotFoundError(error_msg)

with log_step("🔨 Watching documentation…"), suppress(KeyboardInterrupt):
subprocess.run([
sphinx,
command("sphinx-autobuild"),
".",
"-b",
builder,
output if output else "_build", "--watch",
"-D",
f"language={lang or 'en'}",
output if output else "_build",
"--watch",
f"{EXAMPLES_DIR}",
"--ignore",
"**/*.mo",
], check=True, cwd=DOC_DIR)

except KeyboardInterrupt:
click.echo("\nExiting sphinx-autobuild…")

@docs.group()
def locales() -> None:
"""Internationalization-related commands."""


@locales.command()
@click.argument("lang")
def add(lang: str) -> None:
"""Add a new language and create its .po files."""
with log_step(f"🔨 Adding new '{lang}' language…"):
subprocess.run([
command("sphinx-intl"),
"update",
"-p",
"_build/locale",
"-l",
lang,
], check=True, cwd=DOC_DIR)


@locales.command()
def update() -> None:
"""Extract messages and update .po files."""
subprocess.run([
command("sphinx-build"),
".",
"-b",
"gettext",
"_build/locale",
], check=True, cwd=DOC_DIR)

for lang in [
d.name
for d in (DOC_DIR / "locales").iterdir()
if d.is_dir()
]:
subprocess.run([
command("sphinx-intl"),
"update",
"-p",
"_build/locale",
"-l",
lang,
], check=True, cwd=DOC_DIR)


def command(name: str) -> str:
"""Return the full path to a command if found, or raise an error."""
path = shutil.which(name)
if not path:
error_msg = f"The '{name}' command was not found."
raise FileNotFoundError(error_msg)
return path
3 changes: 3 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
]

exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
locale_dirs = ["locales"]
gettext_compact = False
gettext_uuid = True
suppress_warnings = ["misc.highlighting_failure"]
templates_path = ["_templates"]

Expand Down
33 changes: 33 additions & 0 deletions docs/locales/fr/LC_MESSAGES/changelog/v1.0.0.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2025, Gunivers
# This file is distributed under the same license as the Bookshelf package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2025.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Bookshelf \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-05-30 20:14+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\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.17.0\n"

#: ../../changelog/v1.0.0.md:1 8c14ab0a91f3441f920910587d92a5d4
msgid "📦 Gunivers Lib - 1.0.0"
msgstr ""

#: ../../changelog/v1.0.0.md:3 ffa0c4efb42947f096d5750029dd9674
msgid "Data load error: TooLazyException"
msgstr ""

#: ../../changelog/v1.0.0.md:5 3ab53bfab28941e9937ab93d5f98dd49
msgid "Our devs are too busy coding the future to dig up the past..."
msgstr ""

137 changes: 137 additions & 0 deletions docs/locales/fr/LC_MESSAGES/changelog/v2.0.0.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2025, Gunivers
# This file is distributed under the same license as the Bookshelf package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2025.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Bookshelf \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-05-30 20:14+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\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.17.0\n"

#: ../../changelog/v2.0.0.md:1 c695e008533546ffa5c11ee617c119bc
msgid ""
"📦 [Bookshelf - "
"2.0.0](https://github.com/mcbookshelf/bookshelf/releases/tag/v2.0.0)"
msgstr ""

#: ../../changelog/v2.0.0.md:3 808a5c374d744e4bb3ce76b93b203f56
msgid "**🌱 The Flourishing Update!**"
msgstr ""

#: ../../changelog/v2.0.0.md:5 0a55fb3c8b64475ea9d96ffd0e6a8c3b
msgid ""
"*This release replants the foundation of the Gunivers Library, growing "
"into something entirely new.*"
msgstr ""

#: ../../changelog/v2.0.0.md:7 df389fb06fd14d0c9d93cef6597865b0
msgid ""
"**⚠️ BREAKING CHANGES**: This new version is filled with breaking "
"changes. Since maintaining a list of those became unrealistic, the "
"following changelog only highlights a selection of tweaks and new "
"functionalities."
msgstr ""

#: ../../changelog/v2.0.0.md:10 84c39bde92084ddd901a183cdb601e4b
msgid "🎉 Addition"
msgstr ""

#: ../../changelog/v2.0.0.md:12 46d7e24d42424bcb888b475babcce70d
msgid "There is now a changelog!"
msgstr ""

#: ../../changelog/v2.0.0.md:13 faf814c400774ede9b009ff2f5b1d1b2
msgid "Added player health manipulation."
msgstr ""

#: ../../changelog/v2.0.0.md:14 73f7223fb505492cbc8e5c5420ac77a4
msgid "Added precise collisions (move, raycast and view)."
msgstr ""

#: ../../changelog/v2.0.0.md:15 6628b900d52a4dc891b4a269ab0efc28
msgid "Added float manipulation (frexp and ldexp)."
msgstr ""

#: ../../changelog/v2.0.0.md:16 9d933f293d5d45c18d5ebde38625c93c
msgid "Added a new hitbox module."
msgstr ""

#: ../../changelog/v2.0.0.md:17 f0af0b0767484d499f18925840d1e87a
msgid "Added a new raycast module."
msgstr ""

#: ../../changelog/v2.0.0.md:18 666622e5853a4b7fb792752915d90823
msgid "Added a new sidebar module."
msgstr ""

#: ../../changelog/v2.0.0.md:20 278b4c40361d4aa59e68892d28d0969e
msgid "⚡ Enhancements"
msgstr ""

#: ../../changelog/v2.0.0.md:22 296fa7ce938d43168397360475c32eb4
msgid "The project has a new fresh identity: Bookshelf."
msgstr ""

#: ../../changelog/v2.0.0.md:23 916df9ee6a5f4ddca3553d83a51969f9
msgid ""
"Every module has been reworked for improved accuracy, performance, and/or"
" simplicity."
msgstr ""

#: ../../changelog/v2.0.0.md:24 c2cf7a54a87b4ec09aa28a1f8424b258
msgid "Renamed almost everything (scores, objectives, functions, ...)."
msgstr ""

#: ../../changelog/v2.0.0.md:25 e384f23ace934447833c7c2b3b56515d
msgid ""
"Many functions now utilize macros, storage, or fake scores instead of "
"objectives."
msgstr ""

#: ../../changelog/v2.0.0.md:26 7808e521321249d29ace4aa70f957822
msgid "Removed the core module. The library no longer requires a base module."
msgstr ""

#: ../../changelog/v2.0.0.md:27 a98e2614a2c44a1784f1e459d002b9f3
msgid "Removed outdated modules (cache, item, mapedit, and memory)."
msgstr ""

#: ../../changelog/v2.0.0.md:28 5b1e3378fc7e43be935cf19ffc5052c4
msgid "Merged the location and orientation modules into a new position module."
msgstr ""

#: ../../changelog/v2.0.0.md:29 998cf69ae49d47d1a0cb8036a7618c44
msgid ""
"Bitwise operations have been moved out of the math module into a separate"
" module."
msgstr ""

#: ../../changelog/v2.0.0.md:30 3ed000e53ba94f4f9b93d001fb9d211c
msgid ""
"Enhanced the accuracy of the move and view modules due to their rework "
"and the addition of the new hitbox module."
msgstr ""

#: ../../changelog/v2.0.0.md:31 692ce26dd073455f8883c8c3a95c9fab
msgid "The schedule module now maintains the current execution context."
msgstr ""

#: ../../changelog/v2.0.0.md:33 c2403dbfffb84bc98b0b3777b1359769
msgid "🐛 Bug Fixes"
msgstr ""

#: ../../changelog/v2.0.0.md:35 1663a0539bac4720845545d9cda70a39
msgid "Who knows at this point 🤷‍♂️, almost no legacy code remains..."
msgstr ""

Loading
Loading