Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User defined react translations #1698

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
revision = "ffd725001655"
down_revision = "a2a6819f14f1"
branch_labels = ()
depends_on = "cfcb8cb78708"
depends_on = None


def upgrade():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import LanguageDetector from "i18next-browser-languagedetector";
import { translations } from "./messages";
import { initReactI18next } from "react-i18next";

const { languages } = require("./package.json").config;

const options = {
fallbackLng: "en", // fallback keys
returnEmptyString: false,
Expand All @@ -34,4 +36,13 @@ const options = {
const i18next = i18n.createInstance();
i18next.use(LanguageDetector).use(initReactI18next).init(options);

languages.forEach((lng) => {
try {
const overridenTranslations = require(`@overriden_translations/${lng}/LC_MESSAGES/translations.json`);
i18next.addResourceBundle(lng, "translation", overridenTranslations);
} catch (e) {
console.log("No overridden translations found for language", lng);
}
});

export { i18next };
Loading