First iteration of frontend optimized language pack files with ~70% reduced size from full pack

This commit is contained in:
Thomas Lynch
2023-01-27 21:24:17 +11:00
parent 9a0d6d2953
commit 58ba9eebdb
3 changed files with 225 additions and 1 deletions
+6 -1
View File
@@ -471,10 +471,15 @@ const extraLocals = ${JSON.stringify({ meta: config.get.meta, reverseImageLinksU
await del([ 'static/js/lang/' ]);
fs.mkdirSync(`${paths.scripts.dest}lang/`);
const feStrings = require(__dirname+'/tools/festrings.json');
Object.entries(i18n.getCatalog())
.forEach(entry => {
const [lang, dict] = entry;
const langScript = `const LANG = ${JSON.stringify(dict)};`;
const minimalDict = feStrings.reduce((acc, key) => {
acc[key] = dict[key];
return acc;
}, {});
const langScript = `const LANG = ${JSON.stringify(minimalDict)};`;
fs.writeFileSync(`${paths.scripts.dest}lang/${lang}.js`, langScript);
});
+208
View File
@@ -0,0 +1,208 @@
["24h time",
"Add",
"Add layer",
"ago",
"Airbrush",
"Always reveal text spoilers",
"Appeal",
"Appealable?",
"Are you sure? Changing the canvas will clear all layers and history and disable replay recording.",
"Are you sure? Your work will be lost.",
"Attempting to reconnect...",
"Banned!",
"Blur",
"Board",
"Bucket",
"Bumplocked",
"Bypass",
"Cache",
"Canvas height in pixels",
"Canvas width in pixels",
"Captcha",
"Captcha text",
"Clear",
"Close",
"Code theme",
"Color",
"Connected for live posts",
"Connected for live posts (%sms)",
"Could not load the image.",
"Could not load the replay: ",
"Crisp image rendering",
"Custom CSS",
"Cyclic",
"darkgray",
"data-label",
"Default name",
"Delete layers",
"Delete selected layers?",
"Disable board custom CSS",
"Disconnected",
"Do NOT import untrusted settings data!",
"Double click to highlight (%s)",
"Double tap to highlight (%s)",
"Download ",
"Edit",
"Eraser",
"Error connecting",
"Error reconnecting",
"Expiry",
"Export",
"Failed reconnecting",
"Faster",
"Fetching posts...",
"/file/",
"Filter ID",
"Filter Name",
"Filter Subject",
"Filter Tripcode",
"Finish",
"Flow",
"focus to load captcha",
"from now",
"Gapless",
"Global",
"green",
"Hidden images",
"Hidden User",
"Hide",
"Hide deleted post content",
"Hide post stubs",
"Hide thumbnails",
"Hover to view",
"ID",
"Image loading bars",
"Import",
"Import/Export Settings",
"Invalid dimensions.",
"IP/ID",
"IPV4",
"IPV6",
"Issue Date",
"Issuer",
"Layer",
"Layer limit reached.",
"Layers",
"Live posts",
"Live posts off",
"loading",
"Loading replay…",
"Local time",
"Locked",
"Loop audio/video",
"Merge layers",
"Merge selected layers?",
"Message",
"minimised",
"Moderate",
"Move down",
"Move up",
"Name",
"Narrow",
"New",
"No active layer.",
"No appeal submitted",
"No Filters",
"Non-color IDs",
"Note",
"Notifications",
"No video/audio files in this thread.",
"Now",
"OK",
"Only notify (You)s",
"Opacity",
"Open",
"orange",
"Pause",
"Pen",
"Pencil",
"Pipette",
"Play",
"Playlist",
"Please enable JavaScript to solve the captcha.",
"Post Filters",
".postmenu",
"Post password",
"Post(s)",
"Posts not shown",
"Preserve Alpha",
"Pressure",
"Pruned IP",
"Range",
"Reason",
"Recording replay",
"Recursive post hide",
"red",
"Redo",
"Regex?",
"removeAttribute",
"Reverse",
"Reverse Image Search",
"Rewind",
"Right click to replace with the current color",
"%s",
"Save",
"Save As",
"%s characters",
"Scroll to new posts",
"Seen?",
"Select/Drop/Paste files",
"setAttribute",
"%s files",
"%s files selected",
"Show",
"Show relative time",
"Show (You)s",
"Single",
"Size",
"Slower",
"Smooth scrolling",
"Socket error",
"Spoiler",
"Spoiler File",
"%s replies",
"Sticky",
"Strip Filename",
"Subject",
"Submit",
"Success",
"%s UIDs",
"Switch color palette",
"Tegaki Size",
"The active layer is not visible.",
"Theme",
"Thread watcher",
"Thread Watcher",
"thumb/",
"Tip",
"title",
"title-mobile",
"Toggle visibility",
"Tone",
"Tripcode",
"Type",
"undefined",
"Undo",
"Unlimit media height",
"Updated",
"Value",
"Video/Audio volume",
"Watch",
"Watchlist",
"Wide",
"yellow",
"You",
"(You)s",
"Zoom",
"%s day ago",
"%s day from now",
"%s hour ago",
"%s hour from now",
"%s minute ago",
"%s minute from now",
"%s month ago",
"%s month from now",
"%s week ago",
"%s week from now",
"%s year ago",
"%s year from now"]
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
# roughly extract all translation calls used in frontend scripts
grep -ri '__' gulp/res/js/*.js \
| sed 's/__/\n/g' \
| awk -F'))' '{ print $1 }' \
| grep -Po "(?<=')[^',]+(?=')" \
| sort \
| uniq \
| awk '{ print "\""$0"\"""," }'
# | awk -F'__' '{ print $2 }' \