Skip to content
Merged
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
5 changes: 2 additions & 3 deletions src/constants/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { NotificationType as CoreNotificationType } from 'src/core/api';
import { LanguageOption } from 'src/core/api/settings/settings.types';
import { translate } from 'src/core/utils';

export const SocialCauses = {
SOCIAL: 'SOCIAL',
Expand Down Expand Up @@ -890,15 +889,15 @@ export const supportedLanguages: LanguageOption[] = [
label: 'English (US)',
},
{
value: 'jp',
value: 'ja',
label: 'Japanese 日本語',
},
{
value: 'es',
label: 'Spanish Español',
},
{
value: 'kr',
value: 'ko',
label: 'Korean 한국어',
},
];
3 changes: 1 addition & 2 deletions src/core/hooks/useSwitchLanguage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import { supportedLanguages } from 'src/constants/constants';

const useSwitchLanguage = (defaultLanguage = 'en') => {
const [selectedLanguage, setSelectedLanguage] = useState(() => {
return localStorage.getItem('language') || defaultLanguage;
return localStorage.getItem('i18nextLng') || defaultLanguage;
});

const switchLanguage = language => {
if (supportedLanguages.map(lang => lang.value).includes(language)) {
setSelectedLanguage(language);
i18next.changeLanguage(language);
localStorage.setItem('language', language);
window.location.reload();
} else {
console.warn(`Language '${language}' is not supported.`);
Expand Down
6 changes: 3 additions & 3 deletions src/core/translation/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ const resources = {
en: {
translation: generateTranslationFile(),
},
jp: {
ja: {
translation: generateJPTranslationFile(),
},
es: {
translation: generateESTranslationFile(),
},
kr: {
ko: {
translation: generateKRTranslationFile(),
},
};
Expand All @@ -27,7 +27,7 @@ i18next
.use(initReactI18next)
.init({
resources,
lng: localStorage.getItem('language') || 'en',
lng: localStorage.getItem('i18nextLng') || navigator.language || 'en',
fallbackLng: 'en',
interpolation: {
escapeValue: false,
Expand Down
1 change: 0 additions & 1 deletion src/modules/settings/components/Language/useLanguage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import i18next from 'i18next';
import { useState } from 'react';
import { supportedLanguages } from 'src/constants/constants';
import useSwitchLanguage from 'src/core/hooks/useSwitchLanguage';
import { translate } from 'src/core/utils';

export const useLanguage = () => {
const { switchLanguage, selectedLanguage: initialLanguage } = useSwitchLanguage();
Expand Down
Loading