add i18n, products, productors and forms as tables
This commit is contained in:
@@ -5,9 +5,9 @@ import LanguageDetector from "i18next-browser-languagedetector";
|
||||
import { Settings } from "luxon";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
|
||||
import en from "../../locales/en.json";
|
||||
import fr from "../../locales/fr.json";
|
||||
import { Config } from "./config";
|
||||
import en from "@/../locales/en.json";
|
||||
import fr from "@/../locales/fr.json";
|
||||
import { Config } from "@/config/config";
|
||||
|
||||
const resources = {
|
||||
en: { translation: en },
|
||||
@@ -32,10 +32,25 @@ i18next
|
||||
})
|
||||
.then(() => {
|
||||
[Settings.defaultLocale] = i18next.language.split("-");
|
||||
|
||||
i18next.services.formatter?.add(
|
||||
"capfirst",
|
||||
(value) => {
|
||||
if (typeof value !== "string" || !value.length) {
|
||||
return value;
|
||||
}
|
||||
return value.charAt(0).toUpperCase() + value.slice(1);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
export function t(message: string, params?: Record<string, any>) {
|
||||
return i18next.t(message, params);
|
||||
|
||||
export function t(message: string, params?: Record<string, any> & {capfirst?: boolean}) {
|
||||
const result = i18next.t(message, params);
|
||||
if (params?.capfirst && typeof result === "string" && result.length) {
|
||||
return result.charAt(0).toUpperCase() + result.slice(1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export default i18next;
|
||||
|
||||
Reference in New Issue
Block a user