diff --git a/docs/it_IT/welcome.md b/docs/it_IT/welcome.md
new file mode 100644
index 0000000..1fbbc7a
--- /dev/null
+++ b/docs/it_IT/welcome.md
@@ -0,0 +1,73 @@
+# Altra documentazione
+
+Siamo un gruppo di programmer che spendono il loro tempo libero a sviluppare e fare reverse-engineering per i server online per la 3DS e Wii U.
+
+Siamo un gruppo di programmer che spendono il loro tempo libero a sviluppare e fare reverse-engineering per i server online per la 3DS e Wii U.
+
+Siamo un gruppo di programmer che spendono il loro tempo libero a sviluppare e fare reverse-engineering per i server online per la 3DS e Wii U.
+
+```javascript
+function returnTrue() {
+ class trueOrFalseObject {
+ constructor(trueOrFalse) {
+ this.trueOrFalse = trueOrFalse;
+ }
+ get trueOrFalse() {
+ return this.trueOrFalse();
+ }
+ convertNumberToBoolean(trueOrFalse) {
+ if (convertStringToNumber(trueOrFalse) === 0) {
+ return true;
+ } else if (convertStringToNumber(trueOrFalse) == 1) {
+ return false;
+ }
+ }
+ convertStringToNumber(trueOrFalse) {
+ if (trueOrFalse === "true") {
+ return 0;
+ } else if (trueOrFalse === "false") {
+ return true * 69 - 1 - false * 69 * 420 - 69 + 2;
+ }
+ }
+ trueOrFalse() {
+ return this.convertNumberToBoolean(trueOrFalse);
+ }
+ }
+
+ let objectWhichWeKnowIsTrue = new trueOrFalseObject("true");
+
+ function checkIfTrueOrFalse(objectToCheckIfTrueOrFalse) {
+ if (objectToCheckIfTrueOrFalse === objectWhichWeKnowIsTrue.trueOrFalse) {
+ return objectWhichWeKnowIsTrue.trueOrFalse;
+ console.log(
+ "Successfully checked if the object is true or false. Result: the object is true."
+ );
+ // TODO: fix text not console logging
+ } else {
+ objectWhichWeKnowIsTrue = new trueOrFalseObject("false");
+ if (objectToCheckIfTrueOrFalse === objectWhichWeKnowIsTrue.trueOrFalse) {
+ return objectWhichWeKnowIsTrue.trueOrFalse;
+ console.log(
+ "Successfully checked if the object is true or false. Result: the object is false."
+ );
+ // TODO: fix text not console logging
+ } else {
+ // something went horribly wrong
+ }
+ objectWhichWeKnowIsTrue = new trueOrFalseObject("true");
+ }
+ }
+
+ const isTrueTrueOrFalse = checkIfTrueOrFalse("true");
+ const isfalseTrueOrFalse = checkIfTrueOrFalse("false");
+
+ const trueOrFalseJSON = {
+ true: isTrueTrueOrFalse,
+ false: isfalseTrueOrFalse,
+ };
+
+ return trueOrFalseJSON.true
+}
+
+console.log(returnTrue())
+```
diff --git a/locales/en_US.json b/locales/en_US.json
index 936f6e7..1824f8b 100644
--- a/locales/en_US.json
+++ b/locales/en_US.json
@@ -7,7 +7,6 @@
"progress": "Progress",
"blog": "Blog",
"account": "Account",
- "donate": "Donate",
"accountWidget": {
"settings": "Settings",
"logout": "Logout"
@@ -238,7 +237,6 @@
"publishedOn": "on"
},
"account": {
- "account": "Account",
"loginForm": {
"login": "Login",
"register": "Register",
@@ -256,9 +254,7 @@
"downloadFiles": "Download account files",
"downloadFilesDescription": "(will not work on Nintendo Network)",
"upgrade": "Upgrade account",
- "unavailable": "Unavailable",
"settingCards": {
- "userSettings": "User settings",
"profile": "Profile",
"nickname": "Nickname",
"birthDate": "Birth date",
@@ -284,10 +280,7 @@
"linkDiscord": "Link Discord account",
"newsletter": "Newsletter",
"newsletterPrompt": "Receive project updates via email (you can opt-out at any time)",
- "passwordPrompt": "Enter your PNID password to download Cemu files",
- "no_signins_notice": "Sign in history not currently tracked. Check back again later!",
- "no_newsletter_notice": "Newsletter not currently available. Check back again later",
- "no_edit_from_dashboard": "Editing PNID settings from user dashboard is currently unavailable. Please update user settings from your linked game console"
+ "passwordPrompt": "Enter your PNID password to download Cemu files"
}
},
"accountLevel": [
@@ -337,26 +330,10 @@
"caption": "Search for it here"
}
]
- },
- "search": {
- "title": "Got an error code?",
- "caption": "Type it in the box below to get information on your issue!",
- "label": "Error code",
- "no_match": "No matches found"
- },
- "sidebar": {
- "getting_started": "Getting started",
- "welcome": "Welcome",
- "install_extended": "Install Pretendo",
- "install": "Install",
- "search": "Search",
- "juxt_err": "Error codes - Juxt"
-
}
},
"modals": {
"cancel": "Cancel",
- "confirm": "Confirm",
- "close": "Close"
+ "confirm": "Confirm"
}
}
diff --git a/src/routes/account.js b/src/routes/account.js
index fb5f8df..166e185 100644
--- a/src/routes/account.js
+++ b/src/routes/account.js
@@ -70,11 +70,7 @@ router.get('/', requireLoginMiddleware, async (request, response) => {
});
router.get('/login', async (request, response) => {
- const renderData = {
- error: request.cookies.error_message
- };
-
- response.render('account/login', renderData);
+ response.render('account/login');
});
router.post('/login', async (request, response) => {
@@ -101,7 +97,6 @@ router.get('/register', async (request, response) => {
email: request.cookies.email,
username: request.cookies.username,
mii_name: request.cookies.mii_name,
- error: request.cookies.error_message
};
response.clearCookie('email', { domain: '.pretendo.network' });
diff --git a/src/server.js b/src/server.js
index c26f332..940ed15 100644
--- a/src/server.js
+++ b/src/server.js
@@ -12,6 +12,7 @@ const database = require('./database');
const util = require('./util');
const logger = require('./logger');
const config = require('../config.json');
+const defaultLocale = require('../locales/en_US.json');
const { http: { port } } = config;
const app = express();
@@ -136,6 +137,56 @@ app.engine('handlebars', handlebars({
neq(value1, value2) {
return value1 !== value2;
},
+ times(n, block) {
+ let accum = '';
+ for(let i = 0; i < n; i++) {
+ accum += block.fn(i);
+ }
+ return accum;
+ },
+ localeHelper(locale, propString, propVar, extra) {
+ /*
+ locale: the json locale object
+ propString: the "path" to the property to get (e.g. "faq.title")
+ propVar: the dynamic property name to get after the "path" (e.g. localeHelper locale "account.level" would result in )
+ e.g. localeHelper locale "account.test" "account.level" would result in locale.account.test[account.level]
+ */
+
+ let value = locale;
+ const props = propString.split('.');
+
+ if ( typeof propVar === 'string' || propVar instanceof String ||
+ typeof propVar === 'number' || propVar instanceof Number ) {
+ props.push(propVar);
+ }
+
+ function getPropFromLocale(value, props) {
+ for (const p of props) {
+ value = value[p];
+ }
+
+ return value;
+ }
+
+ // fall back to english if the prop doesn't exist in the current locale
+ try {
+ value = getPropFromLocale(value, props);
+ } catch (e) {
+ value = defaultLocale;
+ try {
+ value = getPropFromLocale(value, props);
+ } catch (e) {
+ logger.error(`Could not find locale property ${props.join('.')}`);
+ }
+ }
+
+ // TODO: Make this more dynamic
+ if (extra) {
+ value = value[extra];
+ }
+
+ return value;
+ },
slug(string) {
return string.toLowerCase().replaceAll(/ /g, '-');
}
diff --git a/src/util.js b/src/util.js
index 87149b4..6598b31 100644
--- a/src/util.js
+++ b/src/util.js
@@ -6,14 +6,11 @@ const Stripe = require('stripe');
const { marked } = require('marked');
const { REST: DiscordRest } = require('@discordjs/rest');
const { Routes: DiscordRoutes } = require('discord-api-types/v10');
-const merge = require('lodash.merge');
-
const mailer = require('./mailer');
const database = require('./database');
const logger = require('./logger');
-
const config = require('../config.json');
-const baseLocale = require(`${__dirname}/../locales/en_US.json`);
+
const discordRest = new DiscordRest({ version: '10' }).setToken(config.discord.bot_token);
const stripe = new Stripe(config.stripe.secret_key);
@@ -26,15 +23,12 @@ function getLocale(language, region) {
const path = `${__dirname}/../locales/${language}_${region}.json`;
if (fs.pathExistsSync(path)) {
- const selectedLocale = require(path);
- const finalLocale = merge(baseLocale, selectedLocale);
-
- return finalLocale;
+ return require(path);
}
logger.warn(`Could not find locale ${language}_${region}! Loading en_US`);
- return baseLocale;
+ return require(`${__dirname}/../locales/en_US.json`);
}
function getRawDocs(locale, subpath, pageName) {
diff --git a/views/account/account.handlebars b/views/account/account.handlebars
index 230d70c..2ffe7f6 100644
--- a/views/account/account.handlebars
+++ b/views/account/account.handlebars
@@ -16,29 +16,29 @@
{{tierName}}
{{else}}
{{#if (neq account.access_level -1)}}
- {{ lookup locale.account.accountLevel account.access_level }}
+ {{ localeHelper locale "account.accountLevel" account.access_level }}
{{else}}
- {{ locale.account.banned }}
+ {{ localeHelper locale "account.banned" }}
{{/if}}
{{/if}}
-
+
-
+
-
-
{{ locale.account.settings.settingCards.nickname }}
+ {{ localeHelper locale "account.settings.settingCards.nickname" }}
{{account.mii.name}}
-
-
{{ locale.account.settings.settingCards.birthDate }}
+ {{ localeHelper locale "account.settings.settingCards.birthDate" }}
{{account.birthdate}}
-
-
{{ locale.account.settings.settingCards.gender }}
+ {{ localeHelper locale "account.settings.settingCards.gender" }}
{{account.gender}}
-
-
{{ locale.account.settings.settingCards.country }}
+ {{ localeHelper locale "account.settings.settingCards.country" }}
{{account.country}}
-
-
{{ locale.account.settings.settingCards.timezone }}
+ {{ localeHelper locale "account.settings.settingCards.timezone" }}
{{account.timezone.name}}
-
+
{{#unless isTester}}
-
{{{ locale.account.settings.settingCards.upgradePrompt }}}
+
{{{ localeHelper locale "account.settings.settingCards.upgradePrompt" }}}
{{else}}
-
{{ locale.account.settings.settingCards.hasAccessPrompt }}
+
{{ localeHelper locale "account.settings.settingCards.hasAccessPrompt" }}
{{/unless}}
-
+
-
+
-
-
{{ locale.account.settings.settingCards.email }}
+ {{ localeHelper locale "account.settings.settingCards.email" }}
{{account.email.address}}
-
-
{{ locale.account.settings.settingCards.password }}
+ {{ localeHelper locale "account.settings.settingCards.password" }}
●●●●●●●●
-
{{ locale.account.settings.settingCards.passwordResetNotice }}
+
{{ localeHelper locale "account.settings.settingCards.passwordResetNotice" }}
-
-
{{ locale.account.settings.settingCards.no_signins_notice }}
+
+
Sign in history not currently tracked. Check back again later
{{#each account.devices }}
-
@@ -135,30 +135,30 @@
{{/each}}
-
+
-
+
-
-
{{ locale.account.settings.settingCards.no_newsletter_notice }}
+
+
Newsletter not currently available. Check back again later
@@ -185,22 +185,23 @@
-
{{ locale.account.settings.settingCards.password }}
-
{{ locale.account.settings.settingCards.passwordPrompt }}
+
{{ localeHelper locale "account.settings.settingCards.password" }}
+
{{ localeHelper locale "account.settings.settingCards.passwordPrompt" }}
-
-
+
+
+
-
{{ locale.account.settings.unavailable }}
-
{{ locale.account.settings.settingCards.no_edit_from_dashboard }}
+
Unavailable
+
Editing PNID settings from user dashboard is currently unavailable. Please update user settings from your linked game console
-
+
diff --git a/views/account/login.handlebars b/views/account/login.handlebars
index 6ae3aa3..7664ed6 100644
--- a/views/account/login.handlebars
+++ b/views/account/login.handlebars
@@ -6,22 +6,22 @@
diff --git a/views/account/register.handlebars b/views/account/register.handlebars
index 0c8b726..8419bad 100644
--- a/views/account/register.handlebars
+++ b/views/account/register.handlebars
@@ -7,33 +7,33 @@
diff --git a/views/account/upgrade.handlebars b/views/account/upgrade.handlebars
index 5ef9a07..d353629 100644
--- a/views/account/upgrade.handlebars
+++ b/views/account/upgrade.handlebars
@@ -2,7 +2,7 @@
- {{this.price}} / {{ locale.upgrade.month }}
+ {{this.price}} / {{ localeHelper locale "upgrade.month" }}
{{/each}}
-
-
+
+
-
{{ locale.upgrade.unsub }}
-
{{{ locale.upgrade.unsubPrompt }}}
+
{{ localeHelper locale "upgrade.unsub" }}
+
{{{ localeHelper locale "upgrade.unsubPrompt" }}}
-
-
+
+
-
{{ locale.upgrade.changeTier }}
-
{{{ locale.upgrade.changeTierPrompt }}}
+
{{ localeHelper locale "upgrade.changeTier" }}
+
{{{ localeHelper locale "upgrade.changeTierPrompt" }}}
-
-
+
+
diff --git a/views/blog/blog.handlebars b/views/blog/blog.handlebars
index ee03b0a..d5056e9 100644
--- a/views/blog/blog.handlebars
+++ b/views/blog/blog.handlebars
@@ -7,8 +7,8 @@
@@ -18,12 +18,12 @@
{{{ this.postInfo.title }}}
{{{ this.postInfo.caption }}}
-
{{ ../locale.blogPage.published }}
+
{{ localeHelper ../locale "blogPage.published" }}
{{{ this.postInfo.author }}}
-
{{ ../locale.blogPage.publishedOn }}
+ {{ localeHelper ../locale "blogPage.publishedOn" }}
{{{ this.postInfo.date }}}
diff --git a/views/blog/blogpost.handlebars b/views/blog/blogpost.handlebars
index 21ac56b..dfb61ec 100644
--- a/views/blog/blogpost.handlebars
+++ b/views/blog/blogpost.handlebars
@@ -9,12 +9,12 @@
{{{ postInfo.title }}}
-
{{ locale.blogPage.published }}
+
{{ localeHelper locale "blogPage.published" }}
{{{ postInfo.author }}}
-
{{ locale.blogPage.publishedOn }}
+ {{ localeHelper locale "blogPage.publishedOn" }}
{{{ postInfo.date }}}
diff --git a/views/docs/docs.handlebars b/views/docs/docs.handlebars
index b080960..ec5394c 100644
--- a/views/docs/docs.handlebars
+++ b/views/docs/docs.handlebars
@@ -38,9 +38,15 @@
-
+
+
Note!
+
+ Pretendo Network is currently in closed beta! The servers are only accessible to testers. To become a tester,
+ upgrade your
PNID here
+
+
{{#if missingInLocale}}
-
{{ locale.docs.missingInLocale }}
+
{{ localeHelper locale "docs.missingInLocale" }}
{{/if}}
{{{ content }}}
diff --git a/views/docs/search.handlebars b/views/docs/search.handlebars
index b05907a..339a4a2 100644
--- a/views/docs/search.handlebars
+++ b/views/docs/search.handlebars
@@ -39,9 +39,9 @@