Skip to content

Commit

Permalink
chat/subscriber.go and chat/chat.go: More documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandertv committed Dec 21, 2024
1 parent 71be420 commit b41abec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/player/chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func (chat *Chat) WriteString(s string) (n int, err error) {
return len(s), nil
}

// Writet writes a Translatable message to a Chat, parameterising the message
// using the arguments passed. Messages are translated according to the locale
// of subscribers if they implement Translator. Subscribers that do not
// implement Translator have the fallback message sent.
func (chat *Chat) Writet(t Translatable, a ...any) {
chat.m.Lock()
defer chat.m.Unlock()
Expand Down
4 changes: 4 additions & 0 deletions server/player/chat/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ type Subscriber interface {
Message(a ...any)
}

// Translator is a Subscriber that is able to translate messages to their own
// locale.
type Translator interface {
// Messaget sends a Translatable message to the Translator, using the
// arguments passed to fill out any translation parameters.
Messaget(t Translatable, a ...any)
}

Expand Down

0 comments on commit b41abec

Please sign in to comment.