1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2025-12-20 04:48:48 +00:00

Create initial language support

Create support for languages, then reformat user, home, and post pages
to use it, and create en and en-us language files.
This commit is contained in:
Cadence Ember
2020-07-20 01:40:27 +12:00
parent 1f76e43446
commit 496d53f47e
22 changed files with 319 additions and 54 deletions

View File

@@ -0,0 +1,7 @@
// This file is a template.
const data = {
// CONTENT
}
module.exports = data

51
src/lang/utils/base.txt Normal file
View File

@@ -0,0 +1,51 @@
# Front page
# Top section
go_to_profile
go_to_post
go_username_or_url
go_shortcode_or_url
go_button
# Bottom section
about_bibliogram_header
pug_about_bibliogram_content
about_this_instance_header
onion_site_available
t_settings
t_privacy_policy
has_not_written_privacy_policy
instance_not_blocked
instance_partially_blocked
instance_blocked
rss_enabled
rss_disabled
external_links_header
source_link
matrix_link
instances_link
contact_link
t_featured_profiles
featured_profiles_whats_this
html_featured_profiles_disclaimer
# User page
verified_badge_alt
verified_badge_title
post_counter_label
outgoing_follows_counter_label
incoming_follows_counter_label
t_home
tab_timeline
tab_igtv
next_page_button
next_page_button_loading
profile_is_private_notice
no_posts_notice
no_more_posts_notice
fn_page_divider
# Post page
pug_post_timestamp

View File

@@ -0,0 +1,28 @@
const fs = require("fs").promises
const pj = require("path").join
;(async () => {
const contents = await fs.readFile(pj(__dirname, "base.txt"), "utf8")
const lines = contents.split("\n")
let template = await fs.readFile(pj(__dirname, "base.template.js"), "utf8")
template = template
.replace("// This file is a template.", "// This file was automatically generated and its contents will be overwritten later.")
.replace("// CONTENT", lines
.filter(l => l && !l.startsWith("#"))
.map(l => {
if (l.startsWith("pug_")) {
return `"${l}": locals => "MISSING TEMPLATE: ${l}"`
} else if (l.startsWith("fn_")) {
return `"${l}": () => "MISSING FUNCTION: ${l}"`
} else {
return `"${l}": "MISSING STRING: ${l}"`
}
})
.join(",\n\t")
)
await fs.writeFile(pj(__dirname, "../base.js"), template, "utf8")
console.log("base.js written.")
})()