diff --git a/Makefile b/Makefile index 204cd662..b6bfc6ea 100644 --- a/Makefile +++ b/Makefile @@ -231,11 +231,20 @@ ifneq ($(HAS_SERVER),) $(GO) tool cover -html=server/coverage.txt endif -## Extract strings for translation from the source code. .PHONY: i18n-extract -i18n-extract: +i18n-extract: i18n-extract-webapp i18n-extract-server + +## Extract strings for translation from the source code. +.PHONY: i18n-extract-webapp +i18n-extract-webapp: cd webapp && $(NPM) run i18n-extract -- --out-file src/i18n/en.json --id-interpolation-pattern '[sha512:contenthash:base64:8]' --format simple src/index.tsx src/components/**/*.{ts,tsx} +.PHONY: i18n-extract-server +i18n-extract-server: + $(GO) install -modfile=go.tools.mod github.com/mattermost/mattermost-utilities/mmgotool + cd server && $(GOBIN)/mmgotool i18n extract --portal-dir="" --skip-dynamic + + ## Install NPM dependencies for e2e tests e2e/node_modules: e2e/package.json cd e2e && $(NPM) install diff --git a/go.mod b/go.mod index 13c3cea2..23ef07ba 100644 --- a/go.mod +++ b/go.mod @@ -11,9 +11,11 @@ require ( github.com/invopop/jsonschema v0.7.0 github.com/jmoiron/sqlx v1.3.5 github.com/mattermost/mattermost/server/public v0.0.8 + github.com/nicksnyder/go-i18n/v2 v2.4.0 github.com/r3labs/sse/v2 v2.10.0 github.com/sashabaranov/go-openai v1.24.0 github.com/stretchr/testify v1.8.4 + golang.org/x/text v0.14.0 ) require ( @@ -74,7 +76,6 @@ require ( golang.org/x/crypto v0.12.0 // indirect golang.org/x/net v0.14.0 // indirect golang.org/x/sys v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/grpc v1.56.1 // indirect google.golang.org/protobuf v1.31.0 // indirect diff --git a/go.sum b/go.sum index f6590a3f..ed1b030a 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1 dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= +github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM= github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10= github.com/andygrunwald/go-jira v1.16.0 h1:PU7C7Fkk5L96JvPc6vDVIrd99vdPnYudHu4ju2c2ikQ= @@ -184,6 +186,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= +github.com/nicksnyder/go-i18n/v2 v2.4.0 h1:3IcvPOAvnCKwNm0TB0dLDTuawWEj+ax/RERNC+diLMM= +github.com/nicksnyder/go-i18n/v2 v2.4.0/go.mod h1:nxYSZE9M0bf3Y70gPQjN9ha7XNHX7gMc814+6wVyEI4= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= @@ -357,8 +361,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/go.tools.mod b/go.tools.mod new file mode 100644 index 00000000..602c5b4f --- /dev/null +++ b/go.tools.mod @@ -0,0 +1,5 @@ +module github.com/mattermost/mattermost-plugin-playbooks + +go 1.14 + +require github.com/mattermost/mattermost-utilities/mmgotool v0.0.0-20220104102816-fc494ef2153c // indirect diff --git a/go.tools.sum b/go.tools.sum new file mode 100644 index 00000000..dc462c51 --- /dev/null +++ b/go.tools.sum @@ -0,0 +1,131 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mattermost/mattermost-utilities/mmgotool v0.0.0-20211214093923-17ee7abdc0cc h1:7JWrgvTNfuBHT1vCUca9Hl7XNICid5naUlpTaFcstEs= +github.com/mattermost/mattermost-utilities/mmgotool v0.0.0-20211214093923-17ee7abdc0cc/go.mod h1:3gKozJI8n2Y/vW37GfnFWAdehGXe5yZlt+HykK6Y3DM= +github.com/mattermost/mattermost-utilities/mmgotool v0.0.0-20220104102816-fc494ef2153c h1:ijauqOhwsx09hIio/zKagisOyXIsHXH2vB/+Ed3Bnhg= +github.com/mattermost/mattermost-utilities/mmgotool v0.0.0-20220104102816-fc494ef2153c/go.mod h1:3gKozJI8n2Y/vW37GfnFWAdehGXe5yZlt+HykK6Y3DM= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v1.0.0 h1:6m/oheQuQ13N9ks4hubMG6BnvwOeaJrqSPLahSnczz8= +github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/server/api_post.go b/server/api_post.go index f4f4eeb9..9d826f94 100644 --- a/server/api_post.go +++ b/server/api_post.go @@ -281,7 +281,7 @@ func (p *Plugin) regeneratePost(bot *Bot, post *model.Post, user *model.User, ch case summaryPostIDProp != nil: summaryPostID := summaryPostIDProp.(string) siteURL := p.API.GetConfig().ServiceSettings.SiteURL - post.Message = summaryPostMessage(summaryPostID, *siteURL) + post.Message = p.summaryPostMessage(user.Locale, summaryPostID, *siteURL) var err error result, err = p.summarizePost(bot, summaryPostID, p.MakeConversationContext(bot, user, channel, nil)) @@ -369,7 +369,14 @@ func (p *Plugin) regeneratePost(bot *Bot, post *model.Post, user *model.User, ch } } - p.streamResultToPost(ctx, result, post) + if channel.Type == model.ChannelTypeDirect { + if channel.Name == bot.mmBot.UserId+"__"+user.Id || channel.Name == user.Id+"__"+bot.mmBot.UserId { + p.streamResultToPost(ctx, result, post, user.Locale) + return nil + } + } + + p.streamResultToPost(ctx, result, post, *p.API.GetConfig().LocalizationSettings.DefaultServerLocale) return nil } diff --git a/server/i18n.go b/server/i18n.go new file mode 100644 index 00000000..14b97e07 --- /dev/null +++ b/server/i18n.go @@ -0,0 +1,42 @@ +package main + +import ( + "embed" + "fmt" + + "github.com/nicksnyder/go-i18n/v2/i18n" + "golang.org/x/text/language" +) + +//go:embed i18n/*.json +var i18nFiles embed.FS + +type TranslationFunc func(translationId string, defaultMessage string, params ...any) string + +func i18nInit() *i18n.Bundle { + bundle := i18n.NewBundle(language.English) + bundle.LoadMessageFileFS(i18nFiles, "i18n/es.json") + + return bundle +} + +func i18nLocalizerFunc(bundle *i18n.Bundle, lang string) TranslationFunc { + localizer := i18n.NewLocalizer(bundle, lang) + + return func(translationId string, defaultMessage string, params ...any) string { + if len(params) > 0 { + return fmt.Sprintf(localizer.MustLocalize(&i18n.LocalizeConfig{ + DefaultMessage: &i18n.Message{ + ID: translationId, + Other: defaultMessage, + }, + }), params...) + } + return localizer.MustLocalize(&i18n.LocalizeConfig{ + DefaultMessage: &i18n.Message{ + ID: translationId, + Other: defaultMessage, + }, + }) + } +} diff --git a/server/i18n/en.json b/server/i18n/en.json new file mode 100644 index 00000000..b40fd982 --- /dev/null +++ b/server/i18n/en.json @@ -0,0 +1,38 @@ +[ + { + "id": "copilot.no_longer_access_error", + "translation": "Sorry, you no longer have access to the original thread." + }, + { + "id": "copilot.stream_to_post_access_llm_error", + "translation": "Sorry! An error occurred while accessing the LLM. See server logs for details." + }, + { + "id": "copilot.stream_to_post_llm_not_return", + "translation": "Sorry! The LLM did not return a result." + }, + { + "id": "copilot.summairize_subscription_error", + "translation": "Sorry! Something went wrong. Check the server logs for details." + }, + { + "id": "copilot.summarize_call_recording_processing", + "translation": "Processing audio into transcription. This will take some time..." + }, + { + "id": "copilot.summarize_call_recording_processing_error", + "translation": "Sorry! Something went wrong. Check the server logs for details." + }, + { + "id": "copilot.summarize_recording", + "translation": "Sure, I will summarize this recording: %s/_redirect/pl/%s\n" + }, + { + "id": "copilot.summarize_thread", + "translation": "Sure, I will summarize this thread: %s/_redirect/pl/%s\n" + }, + { + "id": "copilot.summarize_transcription", + "translation": "Sure, I will summarize this transcription: %s/_redirect/pl/%s\n" + } +] diff --git a/server/i18n/es.json b/server/i18n/es.json new file mode 100644 index 00000000..c137d39e --- /dev/null +++ b/server/i18n/es.json @@ -0,0 +1,38 @@ +[ + { + "id": "copilot.no_longer_access_error", + "translation": "Lo siento, ya no tiene acceso al hilo original." + }, + { + "id": "copilot.stream_to_post_access_llm_error", + "translation": "Lo siento, ha ocurrido un error mientras se accedía al LLM. Vea los logs del servidor para más detalles." + }, + { + "id": "copilot.stream_to_post_llm_not_return", + "translation": "Lo siento, el LLM no devolvió resultados." + }, + { + "id": "copilot.summairize_subscription_error", + "translation": "Lo siento, algo fue mal. Vea los logs del servidor para más detalles." + }, + { + "id": "copilot.summarize_call_recording_processing", + "translation": "Procesando transcripción de audio. Esto llevará algo de tiempo..." + }, + { + "id": "copilot.summarize_call_recording_processing_error", + "translation": "Lo siento, algo fue mal, Vea los logs del servidor para más detalles." + }, + { + "id": "copilot.summarize_recording", + "translation": "Claro, resumiré esta grabación: %s/_redirect/pl/%s\n" + }, + { + "id": "copilot.summarize_thread", + "translation": "Claro, resumiré este hilo: %s/_redirect/pl/%s\n" + }, + { + "id": "copilot.summarize_transcription", + "translation": "Claro, resumiré esta transcripción: %s/_redirect/pl/%s\n" + } +] diff --git a/server/meeting_summarization.go b/server/meeting_summarization.go index f7bca1d6..863bbb72 100644 --- a/server/meeting_summarization.go +++ b/server/meeting_summarization.go @@ -100,8 +100,9 @@ func (p *Plugin) createTranscription(recordingFileID string) (*subtitles.Subtitl func (p *Plugin) newCallRecordingThread(bot *Bot, requestingUser *model.User, recordingPost *model.Post, channel *model.Channel, fileID string) (*model.Post, error) { siteURL := p.API.GetConfig().ServiceSettings.SiteURL + T := i18nLocalizerFunc(p.i18n, requestingUser.Locale) surePost := &model.Post{ - Message: fmt.Sprintf("Sure, I will summarize this recording: %s/_redirect/pl/%s\n", *siteURL, recordingPost.Id), + Message: T("copilot.summarize_recording", "Sure, I will summarize this recording: %s/_redirect/pl/%s\n", *siteURL, recordingPost.Id), } surePost.AddProp(NoRegen, "true") if err := p.botDM(bot.mmBot.UserId, requestingUser.Id, surePost); err != nil { @@ -121,8 +122,9 @@ func (p *Plugin) newCallTranscriptionSummaryThread(bot *Bot, requestingUser *mod } siteURL := p.API.GetConfig().ServiceSettings.SiteURL + T := i18nLocalizerFunc(p.i18n, requestingUser.Locale) surePost := &model.Post{ - Message: fmt.Sprintf("Sure, I will summarize this transcription: %s/_redirect/pl/%s\n", *siteURL, transcriptionPost.Id), + Message: T("copilot.summarize_transcription", "Sure, I will summarize this transcription: %s/_redirect/pl/%s\n", *siteURL, transcriptionPost.Id), } surePost.AddProp(NoRegen, "true") surePost.AddProp(ReferencedTranscriptPostID, transcriptionPost.Id) @@ -134,7 +136,7 @@ func (p *Plugin) newCallTranscriptionSummaryThread(bot *Bot, requestingUser *mod // Update to an error if we return one. defer func() { if reterr != nil { - surePost.Message = "Sorry! Somthing went wrong. Check the server logs for details." + surePost.Message = T("copilot.summairize_subscription_error", "Sorry! Something went wrong. Check the server logs for details.") if err := p.pluginAPI.Post.UpdatePost(surePost); err != nil { p.API.LogError("Failed to update post in error handling newCallTranscriptionSummaryThread", "error", err) } @@ -190,9 +192,11 @@ func (p *Plugin) newCallTranscriptionSummaryThread(bot *Bot, requestingUser *mod } func (p *Plugin) summarizeCallRecording(bot *Bot, rootID string, requestingUser *model.User, recordingFileID string, channel *model.Channel) error { + T := i18nLocalizerFunc(p.i18n, requestingUser.Locale) + transcriptPost := &model.Post{ RootId: rootID, - Message: "Processing audio into transcription. This will take some time...", + Message: T("copilot.summarize_call_recording_processing", "Processing audio into transcription. This will take some time..."), } transcriptPost.AddProp(ReferencedRecordingFileID, recordingFileID) if err := p.botDM(bot.mmBot.UserId, requestingUser.Id, transcriptPost); err != nil { @@ -203,7 +207,7 @@ func (p *Plugin) summarizeCallRecording(bot *Bot, rootID string, requestingUser // Update to an error if we return one. defer func() { if reterr != nil { - transcriptPost.Message = "Sorry! Somthing went wrong. Check the server logs for details." + transcriptPost.Message = T("copilot.summarize_call_recording_processing_error", "Sorry! Something went wrong. Check the server logs for details.") if err := p.pluginAPI.Post.UpdatePost(transcriptPost); err != nil { p.API.LogError("Failed to update post in error handling handleCallRecordingPost", "error", err) } @@ -237,7 +241,7 @@ func (p *Plugin) summarizeCallRecording(bot *Bot, rootID string, requestingUser } defer p.finishPostStreaming(transcriptPost.Id) - p.streamResultToPost(ctx, summaryStream, transcriptPost) + p.streamResultToPost(ctx, summaryStream, transcriptPost, requestingUser.Locale) return nil }() diff --git a/server/plugin.go b/server/plugin.go index d85f0106..a8a5d04a 100644 --- a/server/plugin.go +++ b/server/plugin.go @@ -18,6 +18,7 @@ import ( "github.com/mattermost/mattermost/server/public/model" "github.com/mattermost/mattermost/server/public/plugin" "github.com/mattermost/mattermost/server/public/pluginapi" + "github.com/nicksnyder/go-i18n/v2/i18n" ) const ( @@ -59,6 +60,8 @@ type Plugin struct { botsLock sync.RWMutex bots []*Bot + + i18n *i18n.Bundle } func resolveffmpegPath() string { @@ -79,6 +82,8 @@ func (p *Plugin) OnActivate() error { p.licenseChecker = enterprise.NewLicenseChecker(p.pluginAPI) + p.i18n = i18nInit() + if err := p.MigrateServicesToBots(); err != nil { p.pluginAPI.Log.Error("failed to migrate services to bots", "error", err) // Don't fail on migration errors diff --git a/server/post_processing.go b/server/post_processing.go index 22b38b0e..ae7a4cbf 100644 --- a/server/post_processing.go +++ b/server/post_processing.go @@ -140,7 +140,26 @@ func (p *Plugin) streamResultToNewPost(botid string, requesterUserID string, str go func() { defer p.finishPostStreaming(post.Id) - p.streamResultToPost(ctx, stream, post) + user, err := p.pluginAPI.User.Get(requesterUserID) + locale := *p.API.GetConfig().LocalizationSettings.DefaultServerLocale + if err != nil { + p.streamResultToPost(ctx, stream, post, locale) + return + } + + channel, err := p.pluginAPI.Channel.Get(post.ChannelId) + if err != nil { + p.streamResultToPost(ctx, stream, post, locale) + return + } + + if channel.Type == model.ChannelTypeDirect { + if channel.Name == botid+"__"+user.Id || channel.Name == user.Id+"__"+botid { + p.streamResultToPost(ctx, stream, post, user.Locale) + return + } + } + p.streamResultToPost(ctx, stream, post, locale) }() return nil @@ -158,7 +177,26 @@ func (p *Plugin) streamResultToNewDM(botid string, stream *ai.TextStreamResult, go func() { defer p.finishPostStreaming(post.Id) - p.streamResultToPost(ctx, stream, post) + user, err := p.pluginAPI.User.Get(userID) + locale := *p.API.GetConfig().LocalizationSettings.DefaultServerLocale + if err != nil { + p.streamResultToPost(ctx, stream, post, locale) + return + } + + channel, err := p.pluginAPI.Channel.Get(post.ChannelId) + if err != nil { + p.streamResultToPost(ctx, stream, post, locale) + return + } + + if channel.Type == model.ChannelTypeDirect { + if channel.Name == botid+"__"+user.Id || channel.Name == user.Id+"__"+botid { + p.streamResultToPost(ctx, stream, post, user.Locale) + return + } + } + p.streamResultToPost(ctx, stream, post, locale) }() return nil @@ -226,7 +264,8 @@ func (p *Plugin) finishPostStreaming(postID string) { // streamResultToPost streams the result of a TextStreamResult to a post. // it will internally handle logging needs and updating the post. -func (p *Plugin) streamResultToPost(ctx context.Context, stream *ai.TextStreamResult, post *model.Post) { +func (p *Plugin) streamResultToPost(ctx context.Context, stream *ai.TextStreamResult, post *model.Post, userLocale string) { + T := i18nLocalizerFunc(p.i18n, userLocale) p.sendPostStreamingControlEvent(post, PostStreamingControlStart) defer func() { p.sendPostStreamingControlEvent(post, PostStreamingControlEnd) @@ -242,7 +281,7 @@ func (p *Plugin) streamResultToPost(ctx context.Context, stream *ai.TextStreamRe if !ok { if strings.TrimSpace(post.Message) == "" { p.API.LogError("LLM closed stream with no result") - post.Message = "Sorry! The LLM did not return a result." + post.Message = T("copilot.stream_to_post_llm_not_return", "Sorry! The LLM did not return a result.") p.sendPostStreamingUpdateEvent(post, post.Message) } if err = p.pluginAPI.Post.UpdatePost(post); err != nil { @@ -253,12 +292,13 @@ func (p *Plugin) streamResultToPost(ctx context.Context, stream *ai.TextStreamRe } // Handle partial results if strings.TrimSpace(post.Message) == "" { - p.API.LogError("Streaming result to post failed", "error", err) - post.Message = "Sorry! An error occurred while accessing the LLM. See server logs for details." + post.Message = "" } else { - p.API.LogError("Streaming result to post failed partway", "error", err) - post.Message += "\n\nSorry! An error occurred while streaming from the LLM. See server logs for details." + post.Message += "\n\n" } + p.API.LogError("Streaming result to post failed partway", "error", err) + post.Message = T("copilot.stream_to_post_access_llm_error", "Sorry! An error occurred while accessing the LLM. See server logs for details.") + if err := p.pluginAPI.Post.UpdatePost(post); err != nil { p.API.LogError("Error recovering from streaming error", "error", err) return diff --git a/server/service.go b/server/service.go index 811c00e7..cc8243bb 100644 --- a/server/service.go +++ b/server/service.go @@ -111,10 +111,11 @@ func (p *Plugin) continueConversation(bot *Bot, threadData *ThreadData, context if !p.pluginAPI.User.HasPermissionToChannel(context.Post.UserId, threadChannel.Id, model.PermissionReadChannel) || p.checkUsageRestrictions(context.Post.UserId, threadChannel) != nil { + T := i18nLocalizerFunc(p.i18n, context.RequestingUser.Locale) responsePost := &model.Post{ ChannelId: context.Channel.Id, RootId: context.Post.RootId, - Message: "Sorry, you no longer have access to the original thread.", + Message: T("copilot.no_longer_access_error", "Sorry, you no longer have access to the original thread."), } if err = p.botCreatePost(bot.mmBot.UserId, context.RequestingUser.Id, responsePost); err != nil { return nil, err @@ -188,14 +189,15 @@ func (p *Plugin) summarizePost(bot *Bot, postIDToSummarize string, context ai.Co return summaryStream, nil } -func summaryPostMessage(postIDToSummarize string, siteURL string) string { - return fmt.Sprintf("Sure, I will summarize this thread: %s/_redirect/pl/%s\n", siteURL, postIDToSummarize) +func (p *Plugin) summaryPostMessage(locale string, postIDToSummarize string, siteURL string) string { + T := i18nLocalizerFunc(p.i18n, locale) + return T("copilot.summarize_thread", "Sure, I will summarize this thread: %s/_redirect/pl/%s\n", siteURL, postIDToSummarize) } -func (p *Plugin) makeSummaryPost(postIDToSummarize string) *model.Post { +func (p *Plugin) makeSummaryPost(locale string, postIDToSummarize string) *model.Post { siteURL := p.API.GetConfig().ServiceSettings.SiteURL post := &model.Post{ - Message: summaryPostMessage(postIDToSummarize, *siteURL), + Message: p.summaryPostMessage(locale, postIDToSummarize, *siteURL), } post.AddProp(ThreadIDProp, postIDToSummarize) @@ -208,7 +210,7 @@ func (p *Plugin) startNewSummaryThread(bot *Bot, postIDToSummarize string, conte return nil, err } - post := p.makeSummaryPost(postIDToSummarize) + post := p.makeSummaryPost(context.RequestingUser.Locale, postIDToSummarize) if err := p.streamResultToNewDM(bot.mmBot.UserId, summaryStream, context.RequestingUser.Id, post); err != nil { return nil, err }