Closed jpmckinney closed 1 year ago
This happens because the new Go-based Transifex CLI tool provides less API features than the previous Python-based transifex-client, and sphinx-intl relies on the tool not the API.
Maybe should be using transifex-python library?
Let's talk of alternative solution? You want is the resource name (the codelists.pot
you see in the resource list) to be equal to its slug. And you can use transifex-python library for this. See an example below for 'tariffs--1_1--codelists' resource (note the Transifex API token is read from the environment variable TX_TOKEN, so export it or adjust to your case):
import os
from transifex.api import transifex_api
api_token=os.getenv('TX_TOKEN')
transifex_api.setup(auth=api_token)
TRANIFEX_ORGANIZATION='your-organization'
TRANSIFEX_PROJECT='your-project'
ORGANIZATION = transifex_api.Organization.get(slug=TRANIFEX_ORGANIZATION)
PROJECT = ORGANIZATION.fetch('projects').get(slug=TRANSIFEX_PROJECT)
resource = PROJECT.fetch('resources').get(slug='tariffs--1_1--codelists')
resource.name = resource.slug
resource.save('name')
If you want to apply this change to all resources:
...
RESOURCES = transifex_api.Resource.filter(project=TRANSIFEX_PROJECT).all()
for resource in RESOURCES:
resource.name = resource.slug
resource.save('name')
See Transifex Python SDK docs for more info.
I don't think this is a limitation of the new tx
client. I've made a PR with the necessary change. https://github.com/sphinx-doc/sphinx-intl/pull/90 With this PR, I get exactly the behavior I want from the issue description.
The problem is that, if resource_name
is not set, then the new tx
client performs differently than it did before.
Without this PR, sphinx-intl has different behavior in 2.1.0 vs 2.0.1.
If you prefer to have the behavior in the PR be opt-in (or add an opt-out), I can easily add a CLI option for that.
Glad to be wrong and to see a PR for this. Thanks!
Previously, I could use the .tx/config file created by
sphinx-intl update-txconfig-resources
to upload resources, whose name would match the resource ID, e.g. "tariffs--1_1--codelists", which comes from normalizing the resource's local file path.Now, in Transifex, for new resources, the resource shows up with a name that corresponds to the basename of the
source_file
, e.g.codelists.pot
.The earlier behavior can be restored by setting
resource_name
in the config file (i.e. adding--resource-name
to thetx add
command intransifex.py
).If this project doesn't want to hardcode
resource_name
to the resource ID, I would appreciate an opt-in flag for this behavior.