Skip to content

Commit

Permalink
fix i18n.options.fallbackLng
Browse files Browse the repository at this point in the history
We use en-US as source for all translations but had en-GB as fallback. This is now fixed.

Signed-off-by: Daniel Ziegenberg <[email protected]>
  • Loading branch information
ziegenberg committed May 21, 2024
1 parent 34dd129 commit e6f1eee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/src/components/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const About: React.FC = () => {
setAboutContent(response.data);
})
.catch(error => {
axios.get(getURL(typeof i18n.options.fallbackLng === 'string' ? i18n.options.fallbackLng : 'en-GB'))
axios.get(getURL(typeof i18n.options.fallbackLng === 'string' ? i18n.options.fallbackLng : 'en-US'))
.then(response => {
setAboutContent(response.data);
})
Expand Down
8 changes: 4 additions & 4 deletions app/src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import LanguageDetector from "i18next-browser-languagedetector";

// import language files
// @ts-expect-error TS(2307): Cannot find module './org/opencastproject/adminui/... Remove this comment to see the full error message
import enGBTrans from "./org/opencastproject/adminui/languages/lang-en_GB";
// @ts-expect-error TS(2307): Cannot find module './org/opencastproject/adminui/... Remove this comment to see the full error message
import enUSTrans from "./org/opencastproject/adminui/languages/lang-en_US";
// @ts-expect-error TS(2307): Cannot find module './org/opencastproject/adminui/... Remove this comment to see the full error message
import enGBTrans from "./org/opencastproject/adminui/languages/lang-en_GB";
// @ts-expect-error TS(2307): Cannot find module './org/opencastproject/adminui/... Remove this comment to see the full error message
import daDKTrans from "./org/opencastproject/adminui/languages/lang-da_DK";
// @ts-expect-error TS(2307): Cannot find module './org/opencastproject/adminui/... Remove this comment to see the full error message
import deDETrans from "./org/opencastproject/adminui/languages/lang-de_DE";
Expand Down Expand Up @@ -42,8 +42,8 @@ import zhZWTrans from "./org/opencastproject/adminui/languages/lang-zh_TW";
// Assignment of language code to translation file
// !!! If translation file of a new language is added, please add assignment here, too !!!
const resources = {
"en-GB": { translation: enGBTrans },
"en-US": { translation: enUSTrans },
"en-GB": { translation: enGBTrans },
da: { translation: daDKTrans },
de: { translation: deDETrans },
el: { translation: elGRTrans },
Expand All @@ -67,7 +67,7 @@ i18n
.use(initReactI18next)
.init({
resources,
fallbackLng: "en-GB",
fallbackLng: "en-US",
debug: true,

interpolation: {
Expand Down
12 changes: 6 additions & 6 deletions app/src/i18n/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ import zhDate from "date-fns/locale/zh-CN";
* */
const languages = [
{
code: "en-GB",
code: "en-US",
long: "English",
rtl: false,
flag: GBFlag,
dateLocale: enGBDate,
flag: USFlag,
dateLocale: enUSDate,
},
{
code: "en-US",
code: "en-GB",
long: "English",
rtl: false,
flag: USFlag,
dateLocale: enUSDate,
flag: GBFlag,
dateLocale: enGBDate,
},
{ code: "da", long: "Dansk", rtl: false, flag: DKFlag, dateLocale: daDate },
{ code: "de", long: "Deutsch", rtl: false, flag: DEFlag, dateLocale: deDate },
Expand Down
2 changes: 1 addition & 1 deletion app/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const getCurrentLanguageInformation = () => {
// Get code, flag, name and date locale of the current language
let currentLang = languages.find(({ code }) => code === i18n.language);
if (typeof currentLang === "undefined") {
currentLang = languages.find(({ code }) => code === "en-GB");
currentLang = languages.find(({ code }) => code === "en-US");
}

return currentLang;
Expand Down

0 comments on commit e6f1eee

Please sign in to comment.