Translation Finder
Translation file discovery library used by Weblate to identify translation files and their configuration in source repositories.
Discovery can operate on file listings alone or inspect the filesystem when more accurate detection is needed, such as determining file encoding or distinguishing formats with similar syntax.
Maintained by Weblate — a privacy-respecting localization platform built on open-source foundations.
Usage
It can be used from Python:
>>> from translation_finder import discover
>>> from pprint import pprint
>>> results = discover("translation_finder/test_data/")
>>> len(results)
40
>>> pprint(results[0].match)
{'file_format': 'aresource',
'filemask': 'app/src/res/main/values-*/strings.xml',
'name': 'android',
'template': 'app/src/res/main/values/strings.xml'}
>>> pprint(results[1].match)
{'file_format': 'po',
'filemask': 'locales/*.po',
'name': 'translation',
'new_base': 'locales/messages.pot'}
Additional information about discovery can be obtained from meta attribute:
>>> pprint(results[0].meta)
{'discovery': 'TransifexDiscovery', 'origin': 'Transifex', 'priority': 500}
>>> pprint(results[22].meta)
{'discovery': 'GettextDiscovery', 'origin': None, 'priority': 1000}
Or command line:
$ weblate-discovery translation_finder/test_data/
== Match 1 (Transifex) ==
file_format : aresource
filemask : app/src/res/main/values-*/strings.xml
name : android
template : app/src/res/main/values/strings.xml
...
== Match 7 ==
file_format : po
filemask : locales/*.po
new_base : locales/messages.pot
Non-printable characters in command-line results are displayed as visible escapes (for example, \n and \x1b). The Python API returns the original values unchanged.
Discovery limits
The CLI accepts nonnegative integer limits. Zero permits no work for that budget. Defaults are:
--max-candidates: 4096 generated candidates across all backends.
--max-results: 4096 returned matches.
--max-new-base-checks: 65536 new-base lookups across all backends.
--max-masks-per-path: 32 generated masks per path.
--sniff-max-bytes: 67108864 bytes (64 MiB) sampled across the run.
--sniff-max-files: 512 content-sniffing file attempts across the run.
For example, weblate-discover --max-results 10000 translations/ raises only the result limit. weblate-discover --unlimited translations/ disables all six discovery budgets; it cannot be combined with individual limit options. Internal parser safeguards and per-result format and encoding sampling limits remain active.
The CLI prints collected matches to stdout, including partial results. If candidate, result, new-base, or per-path mask limits cause truncation, it prints one warning with the limit reasons to stderr and exits with status 3. Complete discovery exits with status 0; invalid arguments exit with status 2. Sniff-budget exhaustion uses best-effort detection and does not itself report truncation.
Python callers can import DiscoveryLimits from translation_finder.api and pass it as the keyword-only limits argument to discover(). Defaults match the CLI; a field set to None disables that limit, and DiscoveryLimits.unlimited() disables all six. Negative values raise ValueError. Inspect results.truncated and results.limit_reasons for truncation; high-level discovery does not emit Python warnings.
Custom discovery backends
Custom BaseDiscovery implementations return DiscoveryCandidate objects from get_masks(). Each candidate associates the result with the paths which actually generated it, allowing content detection to inspect the group without expanding its wildcard mask again:
Candidate generation, new-base resolution, and returned results are bounded across each discovery run. The returned DiscoveryResults object behaves as a list and exposes truncated and limit_reasons attributes. These report whether a safety limit made results potentially incomplete, without emitting a Python warning.
Calling get_masks() directly is a low-level interface with only the per-path mask limit. Use discover() for run-wide resource bounds and structured limit status.
from translation_finder.discovery.base import BaseDiscovery
from translation_finder.discovery.result import DiscoveryCandidate
class CustomDiscovery(BaseDiscovery):
def get_masks(self, *, eager=False, hint=None):
for path in self.filter_files():
yield DiscoveryCandidate({"filemask": "locale/*.json"}, [path])
Metadata
Release files for translation-finder 3.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| translation_finder-3.8.0.tar.gz | 130.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| translation_finder-3.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 268.0 kB
Release files / translation_finder-3.8.0.tar.gz
| Download URL | translation_finder-3.8.0.tar.gz |
|---|---|
| Size | 130.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f865884e26a0dd409804b5e9f2763f593f3049323d0277c448c27aebabdf51d5
|
|
BLAKE2b-256 checksum How to use checksums |
94278152c9287ce3a8bccfb9ec81a69b86b121d6dd97c4ffffe4d1a507ca5d4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / translation_finder-3.8.0-py3-none-any.whl
| Download URL | translation_finder-3.8.0-py3-none-any.whl |
|---|---|
| Size | 137.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d65307095e53dd9eb711881bac95e47991827d932d69fc16e9b8931d47ada310
|
|
BLAKE2b-256 checksum How to use checksums |
4f47b56982b060ee98f97feec76cf30d6b51fba0fcee8b977438594ced5c4549
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|