logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: f63d9b7835757d28860286f96d22f54196aeb46a
parent 0cc655771642cd840e436a0622e110e69e745338
Author: Tusooa Zhu <tusooa@kazv.moe>
Date:   Mon, 28 Feb 2022 01:28:23 -0500

Use proper lang attributes in htmls

Diffstat:

Mlib/pleroma/web/gettext.ex9+++++++++
Mlib/pleroma/web/templates/feed/feed/tag.atom.eex2+-
Mlib/pleroma/web/templates/layout/app.html.eex2+-
Mlib/pleroma/web/templates/layout/email.html.eex5++---
4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/lib/pleroma/web/gettext.ex b/lib/pleroma/web/gettext.ex @@ -25,4 +25,13 @@ defmodule Pleroma.Web.Gettext do See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage. """ use Gettext, otp_app: :pleroma + + def language_tag do + # Naive implementation: HTML lang attribute uses BCP 47, which + # uses - as a separator. + # https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang + + Gettext.get_locale() + |> String.replace("_", "-", global: true) + end end diff --git a/lib/pleroma/web/templates/feed/feed/tag.atom.eex b/lib/pleroma/web/templates/feed/feed/tag.atom.eex @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom" +<feed xml:lang="<%= Gettext.language_tag() %>" xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:georss="http://www.georss.org/georss" xmlns:activity="http://activitystrea.ms/spec/1.0/" diff --git a/lib/pleroma/web/templates/layout/app.html.eex b/lib/pleroma/web/templates/layout/app.html.eex @@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="<%= Pleroma.Web.Gettext.language_tag() %>"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1,minimal-ui"> diff --git a/lib/pleroma/web/templates/layout/email.html.eex b/lib/pleroma/web/templates/layout/email.html.eex @@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="<%= Pleroma.Web.Gettext.language_tag() %>"> <head> <meta charset="utf-8"> <title><%= @email.subject %></title> @@ -7,4 +7,4 @@ <body> <%= render @view_module, @view_template, assigns %> </body> -</html> -\ No newline at end of file +</html>