Add Translation and Slow Mode docs code samples - #229
Merged
martinmitrevski merged 2 commits intoAug 11, 2026
Conversation
These back two docs pages that previously told Unity readers the features were not available in the SDK, when the client-side APIs already ship: - TranslationCodeSamples - reading `message.I18n`, enabling channel-level auto-translation via `channel.UpdatePartialAsync`, and setting a user's language via `Client.UpsertUsersAsync`. Only the translate endpoint and app-level auto-translation remain server-side. - SlowModeCodeSamples - setting and clearing the channel `cooldown` field, and computing the remaining cooldown from `channel.Cooldown` plus the local user's last message so the send UI can be gated. Keeping them here means the snippets are compiled by StreamChat.Samples and stay in sync with the SDK, matching the existing *CodeSamples.cs files. Docs side: GetStream/docs-content#1497 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
sierpinskid
reviewed
Aug 11, 2026
| namespace StreamChat.Samples | ||
| { | ||
| /// <summary> | ||
| /// Code examples for the features/translation/ docs page |
Member
There was a problem hiding this comment.
best to provide full online URL (like on other examples) so we can easily jump to page from
Contributor
Author
There was a problem hiding this comment.
Done in 536d9dd β switched to the ClientAndUsersCodeSamples.cs convention: a per-method <summary> with the full ?language=unity URL and a section anchor, rather than one class-level comment.
ReadMessageTranslationsβ.../translation/?language=unity#i18n-dataEnableChannelAutoTranslationβ.../translation/?language=unity#enabling-automatic-translationSetUserLanguageβ.../translation/?language=unity#set-user-languageEnableDisableSlowMode,GateSendingUiOnRemainingCooldownβ.../slow-mode/?language=unity#channel-slow-mode
Both pages return 200 and I checked the anchor ids against the rendered HTML, so all five links land on the right section. Both slow mode samples point at the same anchor because that page has no subheading for the remaining-cooldown part β worth splitting on the docs side later.
Matches the convention in ClientAndUsersCodeSamples.cs: a per-method <summary> holding the full ?language=unity URL with a section anchor, so you can jump straight from the sample to the page it backs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
sierpinskid
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested in GetStream/docs-content#1497 β keeping docs snippets compiled here so the SDK and docs stay in sync.
Two new files alongside the existing
*CodeSamples.cs:TranslationCodeSamples.csSlowModeCodeSamples.csWhy these two
Both docs pages carried a
// This feature is not yet available in the Unity SDKplaceholder for every Unity tab, but the client-side APIs already ship:IStreamMessage.I18nexposes the translation dictionary,IStreamChannel.AutoTranslationEnabled/AutoTranslationLanguageexpose the channel settings, andStreamUserUpsertRequest.Languagesets a user's language. Only the translate endpoint and app-level auto-translation are genuinely server-side, and the sample says so in a comment.channel.UpdatePartialAsyncsets thecooldownfield andIStreamChannel.Cooldownreads it back. The second sample computes the remaining cooldown fromCooldownplus the local user's last message, since the SDK doesn't track that for you β this is the part a Unity app needs in order to gate its send button.Notes for review
internal sealed class,private IStreamChatClient Client { get; } = StreamChatClient.CreateDefaultClient();, and doc-extracted regions dedented to column 0.SlowModeCodeSamples.GetRemainingCooldownis the one piece of real logic rather than an API call. It's deliberately framed as "here's how you'd compute this" β if you'd prefer aGetRemainingCooldown()helper onIStreamChannelinstead, that would make both the sample and the docs page a couple of lines long, and I'd happily follow up.develop, but a build on your side would be worth having before merge.π€ Generated with Claude Code