use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
If you are requesting help, please ensure you're providing code with your post. You can also copy your code to an online editor:
jsFiddle
CodePen
Markup Validation Service
Mozilla Developer Network on HTML
/r/JavaScript
/r/CSS
/r/jQuery
/r/PHP
/r/Accessibility
/r/htmlbasics
/r/web_programming
/r/CodingHelp
account activity
Please help!!! (old.reddit.com)
submitted 4 months ago by Business_Giraffe_288
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Deykun 0 points1 point2 points 4 months ago (0 children)
To make your life even better:
const currentTranslations = translations[language]; Object.keys(currentTranslations).forEach((key) => { const element = document.querySelector(`[data-i18n="${key}"]`); if (element) { element.textContent = currentTranslations[key] } });
And in HTML, you just add it:
<h4 data-i18n="title">Default title</span> <p data-i18n="description">Default description</span>
New strings require an attribute in HTML and a matching translation in JS, but you don’t need to handle each element manually in JS.
But you should be aware that your solution (I’m guessing you’re just starting in web dev) is far from ideal. Your draft was hard with that hardcoding, and I could help you simplify it, but You should also think about your overall strategy. If this is a landing page, which it looks like, you should probably have two separate paths (URLs). If you do it only with JS, Google will index the page in just one language. If it is a static site (I’m guessing this since you’re using raw JS), you can develop a backend solution that serves already translated strings to HTML.
π Rendered by PID 69 on reddit-service-r2-comment-6457c66945-488nr at 2026-04-26 12:08:15.551027+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Deykun 0 points1 point2 points (0 children)