Skip to content

Commit 41155da

Browse files
committed
adds default locale setting
1 parent 15ef275 commit 41155da

4 files changed

Lines changed: 221 additions & 278 deletions

File tree

api/src/utils/validateConfig.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
import * as yup from "yup";
2+
import en from "@sqtracker/client/locales/en.json";
3+
import es from "@sqtracker/client/locales/es.json";
4+
import it from "@sqtracker/client/locales/it.json";
5+
import ru from "@sqtracker/client/locales/ru.json";
6+
import de from "@sqtracker/client/locales/de.json";
7+
import zh from "@sqtracker/client/locales/zh.json";
8+
import eo from "@sqtracker/client/locales/eo.json";
9+
import fr from "@sqtracker/client/locales/fr.json";
210

311
const httpRegex = /http(s)?:\/\/.*/;
412
const mongoRegex = /mongodb:\/\/.*/;
@@ -50,6 +58,9 @@ const configSchema = yup
5058
grey: yup.string().matches(hexRegex),
5159
}),
5260
SQ_EXTENSION_BLACKLIST: yup.array().of(yup.string()).min(0),
61+
SQ_SITE_DEFAULT_LOCALE: yup
62+
.string()
63+
.oneOf(["en", "es", "it", "ru", "de", "zh", "eo", "fr"]),
5364
SQ_BASE_URL: yup.string().matches(httpRegex).required(),
5465
SQ_API_URL: yup.string().matches(httpRegex).required(),
5566
SQ_MONGO_URL: yup.string().matches(mongoRegex).required(),

client/pages/_app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ const SqTracker = ({ Component, pageProps, initialTheme }) => {
164164
const [isServer, setIsServer] = useState(true);
165165
const [loading, setLoading] = useState(false);
166166
const [userStats, setUserStats] = useState();
167-
const [locale, setLocale] = useState("en");
168167

169168
const router = useRouter();
170169

@@ -181,9 +180,12 @@ const SqTracker = ({ Component, pageProps, initialTheme }) => {
181180
SQ_API_URL,
182181
SQ_MINIMUM_RATIO,
183182
SQ_MAXIMUM_HIT_N_RUNS,
183+
SQ_SITE_DEFAULT_LOCALE,
184184
},
185185
} = getConfig();
186186

187+
const [locale, setLocale] = useState(SQ_SITE_DEFAULT_LOCALE ?? "en");
188+
187189
const allowThemeToggle = !Object.keys(SQ_CUSTOM_THEME ?? {}).some(
188190
(key) => key !== "primary"
189191
);

config.example.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ module.exports = {
7373
// An array of blacklisted file extensions. Torrents containing files with these extensions will fail to upload.
7474
SQ_EXTENSION_BLACKLIST: ["exe"],
7575

76+
// Default site locale. See `client/locales/index.js` for available options.
77+
SQ_SITE_DEFAULT_LOCALE: "en",
78+
7679
// The URL of your tracker site.
7780
SQ_BASE_URL: "https://sqtracker.dev",
7881

0 commit comments

Comments
 (0)