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.
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:
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.7.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.7.0.tar.gz | 117.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| translation_finder-3.7.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 243.2 kB
Release files / translation_finder-3.7.0.tar.gz
| Download URL | translation_finder-3.7.0.tar.gz |
|---|---|
| Size | 117.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d787afece7697dce5d12bb18f053123be3b6fdeb0ce5273e6cfbedf4b0aa5e0
|
|
BLAKE2b-256 checksum How to use checksums |
20101005dff80e2f831473586552ccc71ee4ad466b4c2ad75e0c7f35f09acda9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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.7.0-py3-none-any.whl
| Download URL | translation_finder-3.7.0-py3-none-any.whl |
|---|---|
| Size | 126.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f64b8a5392aeaf3554c67ecbcf006181c07b129c553c6377fc89d25cd2e5d4f
|
|
BLAKE2b-256 checksum How to use checksums |
4e2ffb1fdf8419b97aa377cf7e16c4075728dd16970997987ad4e6ad7773d006
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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}
|