Allow translating server messages

This commit is contained in:
Trevor Slocum 2024-03-18 13:02:58 -07:00
parent 83730e940d
commit 8e1bf2b628
7 changed files with 24 additions and 18 deletions

View File

@ -1,3 +1,6 @@
1.3.2:
- Allow translating server messages
1.3.1:
- Display doubling cube
- Allow flipping opponent space numbers

View File

@ -32,7 +32,7 @@ Run `~/go/bin/boxcars` to play.
## Translate
Translation is handled [online](https://hosted.weblate.org/projects/bgammon/boxcars/).
Translation is handled [online](https://hosted.weblate.org/projects/bgammon/).
## Support

View File

@ -57,13 +57,13 @@ func (c *Client) logIn() []byte {
} else if game.register {
c.Username = game.Username
c.Password = game.Password
return []byte(fmt.Sprintf("rj %s %s %s %s\nlist\n", AppName, game.Email, game.Username, game.Password))
return []byte(fmt.Sprintf("rj %s/%s %s %s %s\nlist\n", AppName, AppLanguage, game.Email, game.Username, game.Password))
}
loginInfo := strings.ReplaceAll(c.Username, " ", "_")
if c.Username != "" && c.Password != "" {
loginInfo = fmt.Sprintf("%s %s", strings.ReplaceAll(c.Username, " ", "_"), strings.ReplaceAll(c.Password, " ", "_"))
}
return []byte(fmt.Sprintf("lj %s %s\nlist\n", AppName, loginInfo))
return []byte(fmt.Sprintf("lj %s/%s %s\nlist\n", AppName, AppLanguage, loginInfo))
}
func (c *Client) LoggedIn() bool {

View File

@ -40,7 +40,7 @@ import (
)
const (
version = "v1.3.1"
version = "v1.3.2"
baseButtonHeight = 54
MaxDebug = 2
DefaultServerAddress = "wss://ws.bgammon.org"
@ -48,6 +48,8 @@ const (
var AutoEnableTouchInput bool
var AppLanguage = "en"
var (
anyNumbers = regexp.MustCompile(`[0-9]+`)
onlyNumbers = regexp.MustCompile(`^[0-9]+$`)
@ -3086,8 +3088,9 @@ func LoadLocale(forceLanguage *language.Tag) error {
po := gotext.NewPo()
po.Parse(b)
gotext.GetStorage().AddTranslator("boxcars", po)
AppLanguage = useLanguageName
return nil
}

View File

@ -1,6 +1,6 @@
msgid ""
msgstr ""
"PO-Revision-Date: 2024-01-11 07:32+0000\n"
"PO-Revision-Date: 2024-03-18 10:22+0000\n"
"Last-Translator: Iago Emanuel <iagoemanuel@live.com>\n"
"Language-Team: Portuguese (Brazil) <https://hosted.weblate.org/projects/"
"bgammon/boxcars/pt_BR/>\n"
@ -9,7 +9,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 5.4-dev\n"
"X-Generator: Weblate 5.5-dev\n"
msgid "%s - Free Online Backgammon"
msgstr ""
@ -21,10 +21,10 @@ msgid "%s left the match."
msgstr "%s saiu da partida."
msgid "%s moved %s"
msgstr ""
msgstr "%s moveu %s"
msgid "%s rolled %s"
msgstr ""
msgstr "% rolou %"
msgid "%s wins!"
msgstr "%s venceu!"

6
go.mod
View File

@ -3,7 +3,7 @@ module code.rocket9labs.com/tslocum/boxcars
go 1.17
require (
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240315051044-3412f3125003
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240318195851-b2dc9ed64695
code.rocket9labs.com/tslocum/bgammon-tabula-bot v0.0.0-20240220233735-ac7ec51d806c
code.rocket9labs.com/tslocum/etk v0.0.0-20240220192047-d17310185c80
code.rocket9labs.com/tslocum/tabula v0.0.0-20240207195947-691c7a5d5265
@ -54,8 +54,8 @@ require (
github.com/vanng822/css v1.0.1 // indirect
github.com/vanng822/go-premailer v1.20.2 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp/shiny v0.0.0-20240314144324-c7f7c6466f7f // indirect
golang.org/x/mobile v0.0.0-20240213143359-d1f7d3436075 // indirect
golang.org/x/exp/shiny v0.0.0-20240318143956-a85f2c67cd81 // indirect
golang.org/x/mobile v0.0.0-20240318141834-19e4cdff4698 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect

12
go.sum
View File

@ -1,7 +1,7 @@
code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b h1:Y0a14Kf/hSYepSmp4ZfDeE4CZZGBGBS97CNjCbKJm0c=
code.rocket9labs.com/tslocum/bei v0.0.0-20240108012722-6db380cc190b/go.mod h1:tS60/VNAJphKvDBkSLQhKALa15msIAuWWfEKNc4oFZc=
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240315051044-3412f3125003 h1:xO0HT8ZAcPmt2ZYRS4NtWG/WncwfBwy7lMDfQ/C4t0w=
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240315051044-3412f3125003/go.mod h1:cmhRMMrLrsMlG3rhcGbfsPdk0VKSEZMfkFtpRMxm/h8=
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240318195851-b2dc9ed64695 h1:fscnV4JCSBpqZdC+fNxbhU6dH/r7Z9YR/ul5314CZLg=
code.rocket9labs.com/tslocum/bgammon v0.0.0-20240318195851-b2dc9ed64695/go.mod h1:NGFAKlapNeIriQfrrayRBAv2jOuxHhhJH3zokKBJ/Gg=
code.rocket9labs.com/tslocum/bgammon-tabula-bot v0.0.0-20240220233735-ac7ec51d806c h1:q8nqCi++c3qvSxB0KkCOqlDpOn4G77PdX8U/me5gfA4=
code.rocket9labs.com/tslocum/bgammon-tabula-bot v0.0.0-20240220233735-ac7ec51d806c/go.mod h1:WbOquzguDmLic8fYYRiL3n0QFG7+rCsC+PpiXJKfg40=
code.rocket9labs.com/tslocum/etk v0.0.0-20240220192047-d17310185c80 h1:QNlTsKggfZMcybp2xNqO6TWg7rjk6t1/jAV/rmxiX9E=
@ -135,12 +135,12 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/exp/shiny v0.0.0-20240314144324-c7f7c6466f7f h1:QBBTwX973JHUNzDH9uI3LJJl3e+1iM5a2MG/i+ZZ/Gg=
golang.org/x/exp/shiny v0.0.0-20240314144324-c7f7c6466f7f/go.mod h1:3F+MieQB7dRYLTmnncoFbb1crS5lfQoTfDgQy6K4N0o=
golang.org/x/exp/shiny v0.0.0-20240318143956-a85f2c67cd81 h1:JfOcDr8A3W1l+tHaR4QMCL3w6UHsfRRr2845M1TQwX4=
golang.org/x/exp/shiny v0.0.0-20240318143956-a85f2c67cd81/go.mod h1:3F+MieQB7dRYLTmnncoFbb1crS5lfQoTfDgQy6K4N0o=
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
golang.org/x/mobile v0.0.0-20240213143359-d1f7d3436075 h1:iZzqyDd8gFkJZpsJNzveyScRBcQlsveheh6Q77LzhPY=
golang.org/x/mobile v0.0.0-20240213143359-d1f7d3436075/go.mod h1:Y8Bnziw2dX69ZhYuqQB8Ihyjks1Q6fMmbg17j9+ISNA=
golang.org/x/mobile v0.0.0-20240318141834-19e4cdff4698 h1:/slKdBHO/PBcLIwn/elJ1AZYyEAvo9oeIQugV3VUo8Y=
golang.org/x/mobile v0.0.0-20240318141834-19e4cdff4698/go.mod h1:Y8Bnziw2dX69ZhYuqQB8Ihyjks1Q6fMmbg17j9+ISNA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=