Skip to content

Commit

Permalink
[frontend] Add chinese language option
Browse files Browse the repository at this point in the history
  • Loading branch information
RomuDeuxfois authored Aug 20, 2024
1 parent 406fc56 commit 1a7c5de
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
3 changes: 3 additions & 0 deletions openbas-front/src/admin/components/profile/UserForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ const UserForm = ({ onSubmit, initialValues }) => {
<MenuItem key="fr" value="fr">
{t('French')}
</MenuItem>
<MenuItem key="zh" value="zh">
{t('Chinese')}
</MenuItem>
</OldSelectField>
<div style={{ marginTop: 20 }}>
<Button
Expand Down
3 changes: 3 additions & 0 deletions openbas-front/src/admin/components/settings/ParametersForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ const ParametersForm = (props) => {
<MenuItem key="fr" value="fr">
{t('French')}
</MenuItem>
<MenuItem key="zh" value="zh">
{t('Chinese')}
</MenuItem>
</OldSelectField>
<div style={{ marginTop: 20 }}>
<Button
Expand Down
14 changes: 9 additions & 5 deletions openbas-front/src/components/AppIntlProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ const localeMap = {
zh: cnLocale,
};

const momentMap = {
en: 'en-us',
fr: 'fr-fr',
es: 'es-es',
zh: 'zh-cn',
};

const AppIntlProvider = (props) => {
const { children } = props;
const { platformName, lang } = useHelper((helper) => {
Expand All @@ -36,11 +43,8 @@ const AppIntlProvider = (props) => {
return { platformName: name, lang: userLang };
});
const baseMessages = i18n.messages[lang] || i18n.messages[DEFAULT_LANG];
if (lang === 'fr') {
moment.locale('fr-fr');
} else {
moment.locale('en-us');
}
const momentLocale = momentMap[lang];
moment.locale(momentLocale);
useEffect(() => {
document.title = platformName;
}, [platformName]);
Expand Down
2 changes: 1 addition & 1 deletion openbas-front/src/components/DateTimePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const dateFormatsMap = {
'en-us': 'yyyy-MM-dd',
'fr-fr': 'dd/MM/yyyy',
'es-es': 'dd/MM/yyyy',
'zg-cn': 'yyyy-MM-dd',
'zh-cn': 'yyyy-MM-dd',
};

const DateTimePickerBase = ({
Expand Down
2 changes: 1 addition & 1 deletion openbas-front/src/utils/BrowserLanguage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const browserLanguagePropertyKeys = [
'systemLanguage',
];

const availableLanguages = ['en', 'fr'];
const availableLanguages = ['en', 'fr', 'zh'];

const detectedLocale = R.pipe(
R.pick(browserLanguagePropertyKeys), // Get only language properties
Expand Down
4 changes: 3 additions & 1 deletion openbas-front/src/utils/Localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ const i18n = {
Authorization: 'Autorisation',
English: 'Anglais',
French: 'Français',
Chinese: 'Chinois',
Chat: 'Discussion',
Source: 'Source',
Result: 'Résultat',
Expand Down Expand Up @@ -1165,7 +1166,7 @@ const i18n = {
'Rule description': 'Description de la règle',
'Do you want to delete this representation?': 'Voulez-vous supprimer cette représentation ?',
'Trigger time': 'Heure de lancement',
'Attribute mapping configuration': 'Configuration d\'attribut de mappeur',
'Attribute mapping configuration': 'Configuration d\'attribut de mapper',
'The imported file contains absolute dates (ex.: 9h30). A starting date must be provided for the Scenario to be build': 'Le fichier importé contient des dates absolues (ex.: 9h30). Une date de début doit être fournie pour que le scénario puisse être créé',
Test: 'Test',
'Do you want to delete this XLS mapper ?': 'Voulez-vous supprimer ce mappage XLS ?',
Expand Down Expand Up @@ -2315,6 +2316,7 @@ const i18n = {
Authorization: '授权',
English: '英语',
French: '法语',
Chinese: '中国人',
Chat: '聊天',
Source: '来源',
Result: '结果',
Expand Down

0 comments on commit 1a7c5de

Please sign in to comment.