make writefreely translatable for any language

This commit is contained in:
aitzol76 2022-11-24 22:36:21 +01:00
parent 8a74dba40a
commit a0560acbfe
8 changed files with 116 additions and 72 deletions

View File

@ -439,7 +439,7 @@ func handleViewAdminPages(app *App, u *User, w http.ResponseWriter, r *http.Requ
} else if c.ID == "privacy" {
hasPrivacy = true
if !c.Title.Valid {
p.Pages[i].Title = defaultPrivacyTitle()
p.Pages[i].Title = defaultPrivacyTitle(app.cfg)
}
}
}
@ -454,7 +454,7 @@ func handleViewAdminPages(app *App, u *User, w http.ResponseWriter, r *http.Requ
if !hasPrivacy {
p.Pages = append(p.Pages, &instanceContent{
ID: "privacy",
Title: defaultPrivacyTitle(),
Title: defaultPrivacyTitle(app.cfg),
Content: defaultPrivacyPolicy(app.cfg),
Updated: defaultPageUpdatedTime,
})

4
app.go
View File

@ -436,10 +436,8 @@ func handleTemplatedPage(app *App, w http.ResponseWriter, r *http.Request, t *te
page.StaticPage
ContentTitle string
Content template.HTML
ExtraContent template.HTML
PlainContent string
Updated string
//BlogStats template.HTML
AboutStats *InstanceStats
}{
@ -465,8 +463,6 @@ func handleTemplatedPage(app *App, w http.ResponseWriter, r *http.Request, t *te
}
p.ContentTitle = c.Title.String
p.Content = template.HTML(applyMarkdown([]byte(c.Content), "", app.cfg))
//p.ExtraContent = template.HTML(applyMarkdown([]byte(c.ExtraContent), "", app.cfg))
//p.BlogStats = template.HTML(applyMarkdown([]byte(c.BlogStats), "", app.cfg))
p.PlainContent = shortPostDescription(stripmd.Strip(c.Content))
if !c.Updated.IsZero() {
p.Updated = c.Updated.Format("January 2, 2006")

View File

@ -16,6 +16,23 @@ import (
"github.com/writeas/impart"
)
func (app *App) GetLang() string{
//return app.cfg.App.Lang
return "eu_ES"
}
/*
func Lang(cfg *config.Config) string {
return cfg.App.Lang
}
*/
//var setLang = localize(AppCfg.Lang)
//var setLang = localize(cfg.App.Lang)
//var setLang = localize(app.cfg.Lang)
//var setLang = localize(config.Config.AppCfg.Lang)
var iLang = apper.App().GetLang()
var setLang = localize(iLang)
// Commonly returned HTTP errors
var (
ErrBadFormData = impart.HTTPError{http.StatusBadRequest, "Expected valid form data."}
@ -47,7 +64,7 @@ var (
ErrPostUnpublished = impart.HTTPError{Status: http.StatusGone, Message: "Post unpublished by author."}
ErrPostFetchError = impart.HTTPError{Status: http.StatusInternalServerError, Message: "We encountered an error getting the post. The humans have been alerted."}
ErrUserNotFound = impart.HTTPError{http.StatusNotFound, "User doesn't exist."}
ErrUserNotFound = impart.HTTPError{http.StatusNotFound, setLang.Get("User doesn't exist.")}
ErrRemoteUserNotFound = impart.HTTPError{http.StatusNotFound, "Remote user not found."}
ErrUserNotFoundEmail = impart.HTTPError{http.StatusNotFound, "Please enter your username instead of your email address."}

View File

@ -1382,6 +1382,11 @@ msgstr "# Start your blog"
msgid "# Start your blog in the fediverse"
msgstr "# Start your blog in the fediverse"
msgid ""
"## Join the Fediverse\n\nThe fediverse is a large network of platforms that all speak a common language. Imagine if you could reply to _Instagram_ posts from _Twitter_, or interact with your favorite _Medium_ blogs from _Facebook_ -- federated alternatives like %s, %s, and WriteFreely enable you to do these types of things.\n\n"
msgstr ""
"## Join the Fediverse\n\nThe fediverse is a large network of platforms that all speak a common language. Imagine if you could reply to _Instagram_ posts from _Twitter_, or interact with your favorite _Medium_ blogs from _Facebook_ -- federated alternatives like %s, %s, and WriteFreely enable you to do these types of things.\n\n"
msgid ""
"## Write More Socially\n"
"\n"
@ -1400,21 +1405,22 @@ msgstr "_%s_ is a place for you to write and publish, powered by %s."
msgid "_%s_ is an interconnected place for you to write and publish, powered by %s."
msgstr "_%s_ is an interconnected place for you to write and publish, powered by %s."
msgid "_%s_ is home to %d articles across %d blogs."
msgstr "_%s_ is home to %d articles across %d blogs."
msgid "article"
msgid_plural "articles"
msgstr[0] "article"
msgstr[1] "articles"
msgid ""
"## About WriteFreely\n"
"\n"
"%s is a self-hosted, decentralized blogging platform for publishing beautiful, simple blogs.\n"
"\n"
"It lets you publish a single blog, or host a community of writers who can create multiple blogs under one account. You can also enable federation, which allows people in the fediverse to follow your blog, bookmark your posts, and share them with others."
msgstr ""
"## About WriteFreely\n"
"\n"
"%s is a self-hosted, decentralized blogging platform for publishing beautiful, simple blogs.\n"
"\n"
"It lets you publish a single blog, or host a community of writers who can create multiple blogs under one account. You can also enable federation, which allows people in the fediverse to follow your blog, bookmark your posts, and share them with others."
msgid "_%s_ is home to **%d** %s across **%d** %s."
msgstr "_%s_ is home to **%d** %s across **%d** %s."
msgid "About WriteFreely"
msgstr "About WriteFreely"
msgid "%s is a self-hosted, decentralized blogging platform for publishing beautiful, simple blogs."
msgstr "%s is a self-hosted, decentralized blogging platform for publishing beautiful, simple blogs."
msgid "It lets you publish a single blog, or host a community of writers who can create multiple blogs under one account. You can also enable federation, which allows people in the fediverse to follow your blog, bookmark your posts, and share them with others."
msgstr "It lets you publish a single blog, or host a community of writers who can create multiple blogs under one account. You can also enable federation, which allows people in the fediverse to follow your blog, bookmark your posts, and share them with others."
msgid "Start an instance"
msgstr "Start an instance"
@ -1579,3 +1585,7 @@ msgstr "Post was unpublished by the author."
# 410.tmpl 5
msgid "It might be back some day."
msgstr "It might be back some day."
# errors.go
msgid "User doesn't exist."
msgstr "User doesn't exist."

View File

@ -1509,6 +1509,11 @@ msgstr "# Hasi zure bloga"
msgid "# Start your blog in the fediverse"
msgstr "# Hasi zure bloga fedibertsoan"
msgid ""
"## Join the Fediverse\n\nThe fediverse is a large network of platforms that all speak a common language. Imagine if you could reply to _Instagram_ posts from _Twitter_, or interact with your favorite _Medium_ blogs from _Facebook_ -- federated alternatives like %s, %s, and WriteFreely enable you to do these types of things.\n\n"
msgstr ""
"## Batu fedibertsora\n\nFedibertsoa plataforma desberdinek osatzen duten sare zabal bat da, non guztiek hizkuntza bera erabiltzen duten. Imajina ezazu _Twitter_-etik _Instagram_-eko sarrera bat erantzuteko aukera izango bazenu, edo _Facebook_-etik _Medium_ blog plataforman jardutekoa. %s, %s eta WriteFreely bezalako alternatibek horrelako gauzak egitea ahalbidetzen dute.\n\n"
msgid ""
"## Write More Socially\n"
"\n"
@ -1534,25 +1539,22 @@ msgid ""
"_%s_ is an interconnected place for you to write and publish, powered by %s."
msgstr "_%s_ idatzi eta argitaratzeko gune bat da, %s erabiliz."
msgid "_%s_ is home to %d articles across %d blogs."
msgstr "_%s_ idatzi eta argitaratzeko gune bat da, %s erabiliz."
msgid "article"
msgid_plural "articles"
msgstr[0] "artikulu"
msgstr[1] "artikuluak"
msgid ""
"## About WriteFreely\n"
"\n"
"%s is a self-hosted, decentralized blogging platform for publishing "
"beautiful, simple blogs.\n"
"\n"
"It lets you publish a single blog, or host a community of writers who can "
"create multiple blogs under one account. You can also enable federation, "
"which allows people in the fediverse to follow your blog, bookmark your "
"posts, and share them with others."
msgid "_%s_ is home to **%d** %s across **%d** %s."
msgstr "_%s_ guneak **%d** %s ditu, eta **%d** %s."
msgid "About WriteFreely"
msgstr "WriteFreely-ri buruz"
msgid "%s is a self-hosted, decentralized blogging platform for publishing beautiful, simple blogs."
msgstr "%s blog eder eta sinpleak argitaratzeko norberak ostata dezakeen eta deszentralizaturikoa den blogintza plataforma bat da."
msgid "It lets you publish a single blog, or host a community of writers who can create multiple blogs under one account. You can also enable federation, which allows people in the fediverse to follow your blog, bookmark your posts, and share them with others."
msgstr ""
"## WriteFreely-ri buruz\n"
"\n"
"%s blog eder eta sinpleak argitaratzeko norberak ostata dezakeen eta "
"deszentralizaturikoa den blogintza plataforma bat da.\n"
"\n"
"Blog bakar bat argitaratzeko aukera eskaintzen du, edo kontu bakarrean "
"hainbat blog sor ditzakeen idazle komunitate bat ostatatzekoa. Federazioa "
"ere gaitu daiteke, horrela, bertako pertsonek blogak jarraitu, posten laster-"
@ -1737,4 +1739,8 @@ msgstr "Egileak posta ezabatu du."
# 410.tmpl 5
msgid "It might be back some day."
msgstr "Agian itzuliko da egunen batean."
msgstr "Agian itzuliko da egunen batean."
# errors.go
msgid "User doesn't exist."
msgstr "Erabiltzailea ez da existitzen."

View File

@ -37,7 +37,9 @@ func getAboutPage(app *App) (*instanceContent, error) {
}
func defaultAboutTitle(cfg *config.Config) sql.NullString {
return sql.NullString{String: "About " + cfg.App.SiteName, Valid: true}
var setLang = localize(cfg.App.Lang)
title := setLang.Get("About %s", cfg.App.SiteName)
return sql.NullString{String: title, Valid: true}
}
func getPrivacyPage(app *App) (*instanceContent, error) {
@ -54,30 +56,35 @@ func getPrivacyPage(app *App) (*instanceContent, error) {
}
}
if !c.Title.Valid {
c.Title = defaultPrivacyTitle()
c.Title = defaultPrivacyTitle(app.cfg)
}
return c, nil
}
func defaultPrivacyTitle() sql.NullString {
return sql.NullString{String: "Privacy Policy", Valid: true}
func defaultPrivacyTitle(cfg *config.Config) sql.NullString {
var setLang = localize(cfg.App.Lang)
title := setLang.Get("Privacy Policy");
return sql.NullString{String: title, Valid: true}
}
func defaultAboutPage(cfg *config.Config) string {
var setLang = localize(cfg.App.Lang)
wf_link := "[WriteFreely](https://writefreely.org)"
content := setLang.Get("_%s_ is a place for you to write and publish, powered by %s.", cfg.App.SiteName, wf_link)
if cfg.App.Federation {
return `_` + cfg.App.SiteName + `_ is an interconnected place for you to write and publish, powered by [WriteFreely](https://writefreely.org) and ActivityPub.`
content := setLang.Get("_%s_ is an interconnected place for you to write and publish, powered by %s.", cfg.App.SiteName, wf_link)
return content
}
return `_` + cfg.App.SiteName + `_ is a place for you to write and publish, powered by [WriteFreely](https://writefreely.org).`
return content
}
func defaultPrivacyPolicy(cfg *config.Config) string {
return `[WriteFreely](https://writefreely.org), the software that powers this site, is built to enforce your right to privacy by default.
var setLang = localize(cfg.App.Lang)
wf_link := "[WriteFreely](https://writefreely.org)"
bold_site_name := "**"+cfg.App.SiteName+"**"
It retains as little data about you as possible, not even requiring an email address to sign up. However, if you _do_ give us your email address, it is stored encrypted in our database. We salt and hash your account's password.
We store log files, or data about what happens on our servers. We also use cookies to keep you logged in to your account.
Beyond this, it's important that you trust whoever runs **` + cfg.App.SiteName + `**. Software can only do so much to protect you -- your level of privacy protections will ultimately fall on the humans that run this particular service.`
DefPrivPolString := setLang.Get("%s, the software that powers this site, is built to enforce your right to privacy by default.\n\nIt retains as little data about you as possible, not even requiring an email address to sign up. However, if you _do_ give us your email address, it is stored encrypted in our database.\n\nWe salt and hash your account's password.We store log files, or data about what happens on our servers. We also use cookies to keep you logged in to your account.\n\nBeyond this, it's important that you trust whoever runs %s. Software can only do so much to protect you -- your level of privacy protections will ultimately fall on the humans that run this particular service.", wf_link, bold_site_name);
return DefPrivPolString
}
func getLandingBanner(app *App) (*instanceContent, error) {
@ -113,25 +120,27 @@ func getLandingBody(app *App) (*instanceContent, error) {
}
func defaultLandingBanner(cfg *config.Config) string {
//var setLang = localize(cfg)
var setLang = localize(cfg.App.Lang)
banner := setLang.Get("# Start your blog")
if cfg.App.Federation {
return "# Start your blog in the fediverse"
banner := setLang.Get("# Start your blog in the fediverse")
return banner
}
return "# Start your blog"
return banner
}
func defaultLandingBody(cfg *config.Config) string {
var setLang = localize(cfg.App.Lang)
pixelfed := "[PixelFed](https://pixelfed.org)"
mastodon := "[Mastodon](https://joinmastodon.org)"
content1 := setLang.Get("## Join the Fediverse\n\nThe fediverse is a large network of platforms that all speak a common language. Imagine if you could reply to _Instagram_ posts from _Twitter_, or interact with your favorite _Medium_ blogs from _Facebook_ -- federated alternatives like %s, %s, and WriteFreely enable you to do these types of things.\n\n",pixelfed, mastodon)
iframe := `<div style="text-align:center">
<iframe style="width: 560px; height: 315px; max-width: 100%;" sandbox="allow-same-origin allow-scripts" src="https://video.writeas.org/videos/embed/cc55e615-d204-417c-9575-7b57674cc6f3" frameborder="0" allowfullscreen></iframe>
</div>`
content2 := setLang.Get("## Write More Socially\n\nWriteFreely can communicate with other federated platforms like _Mastodon_, so people can follow your blogs, bookmark their favorite posts, and boost them to their followers. Sign up above to create a blog and join the fediverse.")
if cfg.App.Federation {
return `## Join the Fediverse
The fediverse is a large network of platforms that all speak a common language. Imagine if you could reply to Instagram posts from Twitter, or interact with your favorite Medium blogs from Facebook -- federated alternatives like [PixelFed](https://pixelfed.org), [Mastodon](https://joinmastodon.org), and WriteFreely enable you to do these types of things.
<div style="text-align:center">
<iframe style="width: 560px; height: 315px; max-width: 100%;" sandbox="allow-same-origin allow-scripts" src="https://video.writeas.org/videos/embed/cc55e615-d204-417c-9575-7b57674cc6f3" frameborder="0" allowfullscreen></iframe>
</div>
## Write More Socially
WriteFreely can communicate with other federated platforms like Mastodon, so people can follow your blogs, bookmark their favorite posts, and boost them to their followers. Sign up above to create a blog and join the fediverse.`
return content1 + "\n\n" + iframe + "\n\n" + content2
}
return ""
}
@ -156,9 +165,12 @@ func getReaderSection(app *App) (*instanceContent, error) {
}
func defaultReaderTitle(cfg *config.Config) sql.NullString {
return sql.NullString{String: "Reader", Valid: true}
var setLang = localize(cfg.App.Lang)
title := setLang.Get("Reader")
return sql.NullString{String: title, Valid: true}
}
func defaultReaderBanner(cfg *config.Config) string {
return "Read the latest posts from " + cfg.App.SiteName + "."
var setLang = localize(cfg.App.Lang)
return setLang.Get("Read the latest posts form %s.", cfg.App.SiteName)
}

View File

@ -9,16 +9,19 @@
{{if .PublicStats}}
<hr style="margin:1.5em 0;" />
<p><em>{{.SiteName}}</em> is home to <strong>{{largeNumFmt .AboutStats.NumPosts}}</strong> {{pluralize "article" "articles" .AboutStats.NumPosts}} across <strong>{{largeNumFmt .AboutStats.NumBlogs}}</strong> {{pluralize "blog" "blogs" .AboutStats.NumBlogs}}.</p>
{{ $POSTS := .AboutStats.NumPosts }}{{ if eq .AppCfg.Lang "eu_ES" }}{{ $POSTS = 1}}{{ end }}
{{ $BLOGS := .AboutStats.NumBlogs }}{{ if eq .AppCfg.Lang "eu_ES" }}{{ $BLOGS = 1}}{{ end }}
{{ $A := call .Tr "article" $POSTS }}{{ $B := call .Tr "Blog" $BLOGS | tolower }}
<p>{{call .Tr "_%s_ is home to **%d** %s across **%d** %s." true (variables .SiteName .AboutStats.NumPosts $A .AboutStats.NumBlogs $B )}}</p>
{{end}}
{{if not .WFModesty}}
<h2 style="margin-top:2em">About WriteFreely</h2>
<p><a href="https://writefreely.org">WriteFreely</a> is a self-hosted, decentralized blogging platform for publishing beautiful, simple blogs.</p>
<p>It lets you publish a single blog, or host a community of writers who can create multiple blogs under one account. You can also enable federation, which allows people in the fediverse to follow your blog, bookmark your posts, and share them with others.</p>
<h2 style="margin-top:2em">{{call .Tr "About WriteFreely"}}</h2>
<p>{{call .Tr "%s is a self-hosted, decentralized blogging platform for publishing beautiful, simple blogs." true (variables "WriteFreely;https://writefreely.org/")}}</p>
<p>{{call .Tr "It lets you publish a single blog, or host a community of writers who can create multiple blogs under one account. You can also enable federation, which allows people in the fediverse to follow your blog, bookmark your posts, and share them with others."}}</p>
<div class="clearfix blurbs" style="font-size: 1.3em;text-align:center">
<div class="half big">
<p><a href="https://writefreely.org/start">Start an instance</a></p>
<p><a href="https://writefreely.org/start">{{call .Tr "Start an instance"}}</a></p>
</div>
<div class="half big">
<p><a href="https://writefreely.org">WriteFreely</a></p>

View File

@ -1,4 +1,4 @@
{{define "head"}}<title>{{.SiteName}} Reader</title>
{{define "head"}}<title>{{.SiteName}} {{call .Tr "Reader"}}</title>
<link rel="alternate" type="application/rss+xml" title="{{.SiteName}} Reader" href="/read/feed/" />
{{if gt .CurrentPage 1}}<link rel="prev" href="{{.PrevPageURL .CurrentPage}}">{{end}}