mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-18 14:49:01 -06:00
[feature] Set/show instance language(s); show post language on frontend (#2362)
* update go text, include text/display * [feature] Set instance langs, show post lang on frontend * go fmt * WebGet * set language for whole article, don't use FA icon * mention instance languages + other optional config vars * little tweak * put languages in config properly * warn log language parse * change some naming around * tidy up validate a bit * lint * rename LanguageTmpl in template
This commit is contained in:
parent
4ee436e98a
commit
fc02d3c6f7
73 changed files with 55005 additions and 141 deletions
|
|
@ -526,7 +526,7 @@ func (suite *TypeUtilsTestSuite) GetProcessor() *processing.Processor {
|
|||
mediaManager := testrig.NewTestMediaManager(&suite.state)
|
||||
federator := testrig.NewTestFederator(&suite.state, transportController, mediaManager)
|
||||
emailSender := testrig.NewEmailSender("../../web/template/", nil)
|
||||
|
||||
|
||||
processor := testrig.NewTestProcessor(&suite.state, federator, emailSender, mediaManager)
|
||||
testrig.StartWorkers(&suite.state, processor.Workers())
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/language"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/media"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/uris"
|
||||
|
|
@ -656,7 +657,28 @@ func (c *Converter) StatusToWebStatus(
|
|||
s *gtsmodel.Status,
|
||||
requestingAccount *gtsmodel.Account,
|
||||
) (*apimodel.Status, error) {
|
||||
return c.statusToFrontend(ctx, s, requestingAccount)
|
||||
webStatus, err := c.statusToFrontend(ctx, s, requestingAccount)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Add additional information for template.
|
||||
// Assume empty langs, hope for not empty language.
|
||||
webStatus.LanguageTag = new(language.Language)
|
||||
if lang := webStatus.Language; lang != nil {
|
||||
langTag, err := language.Parse(*lang)
|
||||
if err != nil {
|
||||
log.Warnf(
|
||||
ctx,
|
||||
"error parsing %s as language tag: %v",
|
||||
*lang, err,
|
||||
)
|
||||
} else {
|
||||
webStatus.LanguageTag = langTag
|
||||
}
|
||||
}
|
||||
|
||||
return webStatus, nil
|
||||
}
|
||||
|
||||
// statusToFrontend is a package internal function for
|
||||
|
|
@ -873,7 +895,7 @@ func (c *Converter) InstanceToAPIV1Instance(ctx context.Context, i *gtsmodel.Ins
|
|||
ShortDescription: i.ShortDescription,
|
||||
Email: i.ContactEmail,
|
||||
Version: config.GetSoftwareVersion(),
|
||||
Languages: []string{}, // todo: not supported yet
|
||||
Languages: config.GetInstanceLanguages().TagStrs(),
|
||||
Registrations: config.GetAccountsRegistrationOpen(),
|
||||
ApprovalRequired: config.GetAccountsApprovalRequired(),
|
||||
InvitesEnabled: false, // todo: not supported yet
|
||||
|
|
@ -982,7 +1004,7 @@ func (c *Converter) InstanceToAPIV2Instance(ctx context.Context, i *gtsmodel.Ins
|
|||
SourceURL: instanceSourceURL,
|
||||
Description: i.Description,
|
||||
Usage: apimodel.InstanceV2Usage{}, // todo: not implemented
|
||||
Languages: []string{}, // todo: not implemented
|
||||
Languages: config.GetInstanceLanguages().TagStrs(),
|
||||
Rules: c.InstanceRulesToAPIRules(i.Rules),
|
||||
Terms: i.Terms,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -712,7 +712,10 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV1ToFrontend() {
|
|||
"short_description": "\u003cp\u003eThis is the GoToSocial testrig. It doesn't federate or anything.\u003c/p\u003e\u003cp\u003eWhen the testrig is shut down, all data on it will be deleted.\u003c/p\u003e\u003cp\u003eDon't use this in production!\u003c/p\u003e",
|
||||
"email": "admin@example.org",
|
||||
"version": "0.0.0-testrig",
|
||||
"languages": [],
|
||||
"languages": [
|
||||
"nl",
|
||||
"en-gb"
|
||||
],
|
||||
"registrations": true,
|
||||
"approval_required": true,
|
||||
"invites_enabled": false,
|
||||
|
|
@ -826,7 +829,10 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV2ToFrontend() {
|
|||
"thumbnail": {
|
||||
"url": "http://localhost:8080/assets/logo.png"
|
||||
},
|
||||
"languages": [],
|
||||
"languages": [
|
||||
"nl",
|
||||
"en-gb"
|
||||
],
|
||||
"configuration": {
|
||||
"urls": {
|
||||
"streaming": "wss://localhost:8080"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue