Skip to main content

Noctalia i18n Core

简体中文

Noctalia i18n Core is a read-only Python client for project progress, current translations, and changes from Noctalia Translate. Storage, scheduling, delivery, and application policy belong to the caller.

Capabilities

  • Read project details, translation context, and project-wide and per-locale progress.
  • Read current translations as a complete catalog, exact-key results, or text-search results.
  • Query missing translations and translations that need review in a selected locale.
  • List dot-separated translation keys and filter them by hierarchy prefix.
  • Read complete changes for selected keys in one locale.
  • Lazily read the project-wide change stream with locale, time, and anchor boundaries.
  • Read validated change pages with a durable cursor for resumable scans.
  • Retry temporary connection, timeout, rate-limit, and server failures.
  • Use a caller-owned requests.Session when connection policy must be configured by the application.

Project structure

noctalia_i18n_core/
├── client.py   # Website requests and response validation
└── models.py   # Normalized project and change values

Installation

uv add noctalia-i18n-core

Or with pip:

pip install noctalia-i18n-core

Usage

Create a client

from noctalia_i18n_core import NoctaliaClient

with NoctaliaClient("noctalia", timeout=30) as client:
    key = "settings.widgets.settings.scroll-repeat.label"
    value = client.translations(key, locales=("zh-Hans",))[key]["zh-Hans"]
    changes = client.changes(key, locale="zh-Hans")

    print(value)
    print(changes[0].occurred_at if changes else "No changes")

The client retries temporary failures and closes the session it creates. Pass a configured requests.Session when the application owns connection settings such as proxies or retry policy; caller-owned sessions are used without modification.

Project details and progress

project() makes one project request and returns the public name, description, translation context, and current progress. Project and locale progress use the integer percentage shown by the website. The review count identifies translations whose English source changed after that translation was last saved.

project = client.project()

print(project.name, project.key_count, project.language_count, project.progress)
for locale in project.locales:
    print(
        locale.code,
        locale.progress,
        locale.missing_count,
        locale.review_count,
    )

Current translations

translations() reads exact keys in batches of up to 100. Its key-first result preserves the requested key and locale order. A requested key remains present with an empty mapping when no selected locale has a value.

Specify locales to limit response size; omitting it first fetches project metadata to select all configured locales. Reuse one client for connection reuse across calls.

values = client.translations(
    "settings.widgets.settings.scroll-repeat.description",
    "settings.widgets.settings.scroll-repeat.label",
    locales=("zh-Hans", "en"),
)

catalog() makes one complete export request and returns {key: {locale: value}}. It is intended for callers that need every current translation.

catalog = client.catalog()
source_text = catalog["settings.widgets.settings.scroll-repeat.description"]["en"]

search_translations() searches the key and current value in search_locale, follows all result pages, and reads the requested result locales for the matching keys. If locales is omitted, the result contains only search_locale.

matches = client.search_translations(
    "确认",
    search_locale="zh-Hans",
    locales=("zh-Hans", "en"),
)

Missing translations and reviews

missing() returns source entries without a current translation in one locale. reviews() returns entries whose English source changed after the translation was last saved, including the old and new source text and the current translation. Both queries accept query to filter their results.

missing = client.missing("fr", query="scroll")
reviews = client.reviews("fr")

for item in missing:
    print(item.key, item.source, item.translation_url)

for review in reviews:
    print(
        review.key,
        review.old_source,
        review.new_source,
        review.translation,
    )

Translation keys

keys() makes one key-tree request and returns the complete key list. A prefix matches a complete dot-separated hierarchy rather than an arbitrary string prefix.

widget_keys = client.keys(prefix="settings.widgets")

Changes for selected keys

changes() reads the complete changes for one or more exact keys in one locale. The returned tuple is ordered from newest to oldest; multiple key results are merged in that order.

changes = client.changes(
    "settings.widgets.settings.scroll-repeat.description",
    locale="zh-Hans",
)
for change in changes:
    print(change.occurred_at, change.action, change.new_value)

Project change stream

iter_changes() lazily reads the project-wide change stream in the order supplied by the website. since and until are inclusive, timezone-aware boundaries and are normalized to UTC. locale restricts the stream to one locale.

from datetime import UTC, datetime

recent = client.iter_changes(
    locale="zh-Hans",
    since=datetime(2026, 8, 1, tzinfo=UTC),
)
for change in recent:
    print(change.key, change.action)

after is a website change ID. The client confirms the anchor before yielding a result and raises RuntimeError when it is absent. on_progress receives the completed page number and current total page count after each request.

change_pages() exposes the same stream as immutable ChangePage values. start_page selects a one-based page. cursor is an opaque resume position stored by the caller; the client discards that position and newer records before continuing with older pages.

page = next(client.change_pages(start_page=1))
print(page.number, page.total_pages, page.cursor)

API reference

NoctaliaClient

NoctaliaClient(project, *, timeout, session=None)

project is the website project identifier. timeout is a positive finite number of seconds applied to each attempt. By default, temporary connection, timeout, rate-limit, and server failures are retried three times with backoff. session may be a caller-owned requests.Session; its transport policy is preserved and the client does not close it.

Queries spanning multiple requests are not atomic snapshots.

Member Result
slug The project identifier passed to the constructor
translation_url(key, locale) Translation page for one key and locale
project() Project details and current translation progress
keys(*, prefix=None) tuple[str, ...] of complete or prefix-matched keys
catalog() dict[str, dict[str, str]] containing the complete current catalog
translations(key, *keys, locales=None) Key-first exact translations
search_translations(query, *, search_locale, locales=None) Key-first translations for text matches
missing(locale, *, query=None) Missing translations with their source text
reviews(locale, *, query=None) Translations needing review in one locale
changes(key, *keys, locale) Newest-first exact-key changes
iter_changes(*, locale=None, since=None, until=None, after=None, on_progress=None) Lazy project-wide change iterator
change_pages(*, locale=None, start_page=1, cursor=None) Lazy validated pages with an opaque resume cursor
close() Closes an owned HTTP session

translations() and changes() require at least one positional key. translations() returns requested keys even when their result is empty. changes() returns a tuple and requests each selected key from the website. iter_changes() never accepts keys and remains lazy until iteration begins.

Invalid arguments raise ValueError. Network failures that remain after retries and responses that do not match the website contract raise RuntimeError.

Project and Locale

Project contains public project details and progress aggregated from the current locale states:

Field or property Description
slug Website project identifier
name Project name
description Project description, or None when absent
translation_context Translation guidance and terminology, or None when absent
key_count Current translation key count
locales Website-ordered tuple[Locale, ...]
language_count Configured locale count
translation_count Current translation count
missing_count Current missing translation count
review_count Current translations that need review
progress Integer completion percentage shown by the website

Each Locale contains code, translation_count, missing_count, review_count, and the derived progress. Locales without any current translations remain present in the project result.

Missing and Review

Missing contains key, locale, source, and translation_url. source is None when the key has no English translation. Review contains key, locale, old_source, new_source, translation, and translation_url; old_source is None when the website has no earlier source text. The source difference is distinct from changes to the translation itself.

Change

Each change has the following fields:

Field Description
id Website change identifier
key Translation key
locale Locale changed by the record
action added, modified, or deleted
actor Contributor login, or API for an automated change
old_value Previous text, or None for an addition
new_value New text, or None for a deletion
occurred_at UTC-aware datetime
translation_url Translation page for the key and locale

ChangeAction is the literal type "added" | "modified" | "deleted". SOURCE_LOCALE is "en".

ChangePage

ChangePage contains number, total_pages, changes, and cursor. cursor corresponds to the final raw website record on the page, including a record that normalizes to no Change; callers should treat it only as an opaque resume value.

Development

Install the locked development environment:

uv sync --locked

Run formatting, linting, type checking, and tests:

uv run --locked ruff format --check .
uv run --locked ruff check .
uv run --locked pyrefly check
uv run --locked python -m unittest discover -v

The default suite validates models, response parsing, and client behavior without accessing external services.

Run the live contract tests explicitly to verify every public operation against the current public projects on Noctalia Translate:

uv run --locked python -m unittest tests.live -v

Build and inspect both distributions:

uv build --no-sources --clear
uvx twine check --strict dist/*

License

MIT

Metadata

Release files for noctalia-i18n-core 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for noctalia-i18n-core 0.5.0
File Size Uploaded Provenance Actions
noctalia_i18n_core-0.5.0.tar.gz 28.2 kB With provenance Details for noctalia_i18n_core-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for noctalia-i18n-core 0.5.0
File Interpreter ABI Platform Actions
noctalia_i18n_core-0.5.0-py3-none-any.whl Python 3 none any Details for noctalia_i18n_core-0.5.0-py3-none-any.whl

Total release size: 45.7 kB

Release files / noctalia_i18n_core-0.5.0.tar.gz

Download URL noctalia_i18n_core-0.5.0.tar.gz
Size 28.2 kB
Tags Source
SHA-256 checksum
How to use checksums
336671bc9af8e04ebaf2d2a7c6712f0f9c5d6da53f4446b9741431704a09bfe4
BLAKE2b-256 checksum
How to use checksums
11d44e8228e8fc716ac25d745d6719f5869d5b7aaf54e43aef1b678accb77f41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / noctalia_i18n_core-0.5.0-py3-none-any.whl

Download URL noctalia_i18n_core-0.5.0-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a4b2006cde854d96d0395227d34db2f110313238bf6d5e9e85f9bec64baca12
BLAKE2b-256 checksum
How to use checksums
318ac649fe5d6dde2de6ec4675218dcf65623b40db1532c6b6246ee3fe5439fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for noctalia-i18n-core 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for noctalia_i18n_core-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page