mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02: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:
@ -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,
|
||||
}
|
||||
|
Reference in New Issue
Block a user