Skip to content

Commit

Permalink
[Bug]: Fixed localisation for subpath (ToolJet#4057)
Browse files Browse the repository at this point in the history
* Fixed localisation for subpath

* Fixed notification typo on localisation
  • Loading branch information
kavinvenkatachalam authored Sep 21, 2022
1 parent 9860cf6 commit 3ae99ad
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
12 changes: 7 additions & 5 deletions frontend/src/_components/NotificationCenter/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const NotificationCenter = () => {
</p>
<p className="empty-subtitle text-muted">
{`${t('header.notificationCenter.youDontHaveany', `You don't have any`)} ${
!isRead && t('header.notificationCenter.un', 'un')
!isRead ? t('header.notificationCenter.un', 'un') : ''
}${t('header.notificationCenter.read', 'read')} ${t(
`header.notificationCenter.notifications`,
'notifications'
Expand All @@ -108,10 +108,12 @@ export const NotificationCenter = () => {
</div>
<div className="card-footer text-center margin-auto">
<a href="#" className="text-muted text-decoration-none" onClick={() => setIsRead(!isRead)}>
{`${t('header.notificationCenter.view', 'View')} ${isRead && t('header.notificationCenter.un', 'un')}${t(
'header.notificationCenter.read',
'read'
)} ${t(`header.notificationCenter.notifications`, 'notifications').toLowerCase()}`}
{`${t('header.notificationCenter.view', 'View')} ${
isRead ? t('header.notificationCenter.un', 'un') : ''
}${t('header.notificationCenter.read', 'read')} ${t(
`header.notificationCenter.notifications`,
'notifications'
).toLowerCase()}`}
</a>
</div>
</div>
Expand Down
20 changes: 0 additions & 20 deletions frontend/src/i18n.js

This file was deleted.

19 changes: 18 additions & 1 deletion frontend/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { Integrations } from '@sentry/tracing';
import { createBrowserHistory } from 'history';
import { appService } from '@/_services';
import { App } from './App';
import './i18n';
// eslint-disable-next-line import/no-unresolved
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import Backend from 'i18next-http-backend';

const AppWithProfiler = Sentry.withProfiler(App);

Expand All @@ -14,6 +18,19 @@ appService
.then((config) => {
window.public_config = config;

const path = config?.SUB_PATH || '/';
i18n
.use(Backend)
.use(LanguageDetector)
.use(initReactI18next)
.init({
load: 'languageOnly',
fallbackLng: 'en',
backend: {
loadPath: `${path}assets/translations/{{lng}}.json`,
},
});

if (window.public_config.APM_VENDOR === 'sentry') {
const history = createBrowserHistory();
const tooljetServerUrl = window.public_config.TOOLJET_SERVER_URL;
Expand Down

0 comments on commit 3ae99ad

Please sign in to comment.