Support for tl=[lang] parameters in REST API (for non-anon users)

AI-generated summary

The discussion revolves around support for the tl=[lang] parameter in the Discourse REST API for non-anonymous users. jrgong seeks to retrieve localized posts from closed categories, noting that the parameter currently only works for anonymous users. pfaffman suggests reverse engineering the API as a general approach. pmusaraj confirms the parameter works for them on certain endpoints, such as /posts/id.json, returning French content when tl=fr is used. jrgong clarifies they are logged in and still unable to access localized content. nat confirms that the tl parameter is restricted to anonymous users, citing a GitHub issue, and jrgong expresses disappointment, stating they need this functionality for logged-in users to access localized content in closed categories.

In our use case, we are trying to GET localized posts from closed categories in our forum.

It would be a neat addition for the REST API to support ?tl=en as a parameter to pull the translated version of the cooked post.

Currently, the tl param only works for anons.

2 Likes

In general, if you want to find out about the API, the fastest way is to Reverse engineer the Discourse API

1 Like

This already works for me, for example the current topic with .json?tl=fr gives the right response, notice that cooked is in French:

A post was split to a new topic: Tl=lang crawler view not showing posts in lang

I tried exactly that via /posts/id.json endpoint, but get just the original version in cooked.

Could you check on your end? https://meta.discourse.org/posts/1887991.json?tl=fr

That endpoint works for me, it returns cooked in French. If I switch to tl=es, it returns cooked in Spanish.

Are you calling these endpoints from a specific user? On my end, I am making the requests anonymously.

yep, I do them while logged in. And that’s actually what I am trying to achieve since I want to be able to GET posts from closed categories in our forum.

1 Like

The tl param only works for anons.

3 Likes

Thx for the confirmation! I will edit first post into a feauture request then