How to get a list of languages to which a specific resource was translated?

Using the Python SDK (latest version). I have:

resource = project.fetch("resources").get(slug=resource_slug)

Is there a method on resource to list the languages which the resource has translations strings for? If not, how can I extract such a list?

1 Like

Good morning,
Thank you for contacting us. I can see you have deleted the message you had sent.
Is there something we can help you with ?
Have you resolved the issue?

Could you please what are you trying to achieve so that we can help you with your use case?

Kind regards
Christos

Thank you for your attentive reply; the answer is No, I havenā€™t fully resolved my issue. Hereā€™s some context. I am using the Python SDK. My goal is to extract a list of language codes of all translations available under a given project and resource slug. Hereā€™s a my code:

if resource := project.fetch("resources").get(slug=resource_slug):
    it = tx_api.ResourceLanguageStats.filter(
        project=project, 
        resource=resource
    ).all()
    
    language_codes = []
    for tr in it:
        # trying to do something with 'tr' here
        # to get the tr's language codes...                

Now perhaps I missed something and ResourceLanguageStats is not the appropriate class to use. I donā€™t mind as long as I can get the data I am looking forā€¦

So the goal is not to get all language codes that are a declared target language on Transifex project but just those that have been (not exclusively fully) translated. correct?

Hum, maybe? Not sure whether what youā€™re saying = what I am saying. What I would like to extract: all the languages with any number of translation strings for the given <project, resource> pair.

Yes , i believe we are on the same page here. Allow me to do some testing

Okay, thanks! Standing by

Hello @MrNycticorax ,
I am Panagiotis from the Transifex support team, a colleague of @chrisb .

Allow me to chime in here since I would like to understand your need better. I understand what you wrote, but what need do you want to cover?

Every project has specific target languages. So, the projectā€™s target languages are the same for all the project resources. Letā€™s take the following example:

You have Project A, with English as Source Language and FR and ES as target languages.
Under this project, you have the following four resources.

  • -Resource R1
  • -Resource R2
  • -Resource R3
  • -Resource R4

Letā€™s assume that:

Resource R1 has been translated at 35% both in FR and ES
Resource R2 has only one string translated in FR and none strings translated in ES
Resource R3 has 0 strings translated both in FR and ES.
Resource R4 has none strings translated in FR and 100% translated strings in ES.

What are you looking for in the above example?

Thank you in advance for your answer!

Kind regards,
Panagiotis
Principal Success Engineer at Transifex

Hello Panagiotis,

Thanks for chiming in! I am grateful for your debunking my mistaken assumption that different resources under the same project could have different target languages for translations. Thanks for that!

So to answer your question, bearing in mind your example, Iā€™d like to produce the list [fr, es], or any similar list including the language codes for the two target languages.

I thought Iā€™d be able to do exactly this with the snippet at How to get a list of languages to which a specific resource was translated? - #3 by MrNycticorax but I could not.

Hi @MrNycticorax ,

Thank you for your response. So, according to your last response, you are looking for the list of the target languages of a specific project.

In that case, you need to use the following command

project.fetch("languages").all()

I would also recommend to have a look at similar examples under our Guide with Recipes

The above-highlighted example is how to get a list of all the available languages of a project.

Please let me know if you have any further questions.

Kind regards,
Panagiotis
Principal Success Engineer at Transifex

Superb, thanks and happy successes!

(tried to mark as ā€˜resolvedā€™, didnā€™t find any button, but the above can be considered as resolved. Also idea: Discourse Solved - plugin - Discourse Meta)