Skip to content

Conversation

@nattsw
Copy link
Contributor

@nattsw nattsw commented Feb 10, 2025

This feature shows a fully translated topic in the user's language. For now, the topic needs to already have translations for the translated topic to show. If there are posts that have not been translated, the original content will be shown.

Topic fully translated to site locale:

Screenshot 2025-02-10 at 8 17 08 PM

Topic fully translated to lang param:

Screenshot 2025-02-10 at 8 17 27 PM

Show original content of topic

Screenshot 2025-02-10 at 8 21 06 PM

The translated_title is returned via the TopicViewSerializer and displayed via the applyTransformations API.
The translated_cooked is returned via the PostSerializer and displayed via decorateCooked.

This takes a different approach from the previous PR #199 which overrode the fancy_title and cooked directly.

const translatedCooked = helper.getModel().get("translated_cooked");
if (translatedCooked) {
cookedElement.innerHTML = translatedCooked;
} else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm more familiar with ruby so I genuinely am not sure, but in this case do we even want the else for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's just a note to indicate it's a missing feature. Should not cost much.

@nattsw
Copy link
Contributor Author

nattsw commented Feb 11, 2025

Thank you @jbrw.

@nattsw nattsw merged commit 3537345 into main Feb 11, 2025
5 checks passed
@nattsw nattsw deleted the translate-full-topics-no-monkey branch February 11, 2025 06:08
nattsw added a commit that referenced this pull request Feb 14, 2025
…slation values (#210)

In #205, we returned translated values using existing JS apis. While this was convenient, it does not allow us to modify crawler views such as ...

https://github.com/discourse/discourse/blob/main/app/views/topics/show.html.erb 

... when we want to serve translated pages.

This commit makes use of discourse/discourse#31261 to override the values.
nattsw added a commit to discourse/discourse that referenced this pull request May 15, 2025
Related:
- discourse/discourse-translator#205
- discourse/discourse-translator#274
- discourse/discourse-translator#294

With this PR, we will start showing localized posts (if available) based
on the user's locale.

This work had been done in discourse-translator, but is now moving to
core.
nattsw added a commit to discourse/discourse that referenced this pull request May 26, 2025
In #32618, the button was
added to a place which does not show up on mobile.

When the feature was still in discourse-translator
(discourse/discourse-translator#205), it was
added to the plugin outlet which would allow it to show up on both
mobile and desktop. This commit moves the button to be a neighbour of the
plugin outlet.
martin-brennan pushed a commit to discourse/discourse that referenced this pull request Jun 10, 2025
Related:
- discourse/discourse-translator#205
- discourse/discourse-translator#274
- discourse/discourse-translator#294

With this PR, we will start showing localized posts (if available) based
on the user's locale.

This work had been done in discourse-translator, but is now moving to
core.
martin-brennan pushed a commit to discourse/discourse that referenced this pull request Jun 10, 2025
In #32618, the button was
added to a place which does not show up on mobile.

When the feature was still in discourse-translator
(discourse/discourse-translator#205), it was
added to the plugin outlet which would allow it to show up on both
mobile and desktop. This commit moves the button to be a neighbour of the
plugin outlet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants