Currently when changing the language from application, the locale is not updated. it will keep the default locale of days. that need to change.
Locale dayjs need to be updated according to the use language selection.
https://github.com/jhipster/generator-jhipster/issues/12575
@FabienEssid and myself started looking on how to add the improvement.
dayjs.locale(LOCALE_VALUE)A confirm the issue for angular. ~It works for vue.~ I was wrong, it also doesn't work for vue.
I think for vue it can be added to translation.service.ts in refreshTranslation. Need to check for angular/react
It works for vue by extending translation.service.ts as follows:
import axios from 'axios';
import dayjs from 'dayjs';
import VueI18n from 'vue-i18n';
import { Store } from 'vuex';
import { BUILD_TIMESTAMP } from '@/constants';
export default class TranslationService {
private store: Store<{}>;
private i18n: VueI18n;
constructor(store: Store<{}>, i18n: VueI18n) {
this.store = store;
this.i18n = i18n;
}
public refreshTranslation(newLanguage: string) {
let currentLanguage = this.store.getters.currentLanguage;
currentLanguage = newLanguage ? newLanguage : 'en';
if (this.i18n && !this.i18n.messages[currentLanguage]) {
this.i18n.setLocaleMessage(currentLanguage, {});
dayjs.locale(currentLanguage);
axios.get(`i18n/${currentLanguage}.json?buildTimestamp=${BUILD_TIMESTAMP}`).then(res => {
if (res.data) {
this.i18n.setLocaleMessage(currentLanguage, res.data);
this.i18n.locale = currentLanguage;
this.store.commit('currentLanguage', currentLanguage);
}
});
} else if (this.i18n) {
this.i18n.locale = currentLanguage;
dayjs.locale(currentLanguage);
this.store.commit('currentLanguage', currentLanguage);
}
}
}
@medamineziraoui Would you like to do a PR? If you need more help don't hesitate to reach out here.
Hello @atomfrede yes i would love to, this would be my first contribution if done successfully so definitely would not hesitate to ask if I need help.
@medamineziraoui Awesome! I think for angular you need to look here and for react it could be done in the locale reducer/store
@atomfrede Thank you
@medamineziraoui is currently on holidays. We should work on this issue when he'll be back next week :slightly_smiling_face:
Hello im starting working on this issue today, i will keep you updated with my progress :slightly_smiling_face:
TranslatorContextexport type LocaleState = Readonly<typeof initialState>;
export default (state: LocaleState = initialState, action): LocaleState => {
switch (action.type) {
case ACTION_TYPES.SET_LOCALE: {
const currentLocale = action.locale;
if (state.currentLocale !== currentLocale) {
dayjs.locale(currentLocale); // <====== updated this dayjs locale before setting state in the TranslatorContext
TranslatorContext.setLocale(currentLocale);
What do think about updating React this way to fixe the dayjs locale?


<jhipster-dependencies.version>7.0.0-SNAPSHOT</jhipster-dependencies.version>
jhipster-dependencies.version to 0.1,0
This ofc broke multiple parts in the project but it was enough for us to test what we need for Vuejs and Reactjs.
@medamineziraoui You need to checkout jhipster-bom project and build it locally.
There is no breaking change between released version 0.1.0 and current master (7.0.0-SNAPSHOT) of jhipster-bom project until now... But better to always compile it locally.
Thank you for your answer @DanielFran, are you talking about this repo ? https://github.com/jhipster/jhipster-bom
Is there anything else I need to do ( any change in configuration for generated project ?)
Yes, it is this repo. No changes required on generator side...
Please follow the instructions how to build jhipster-bom project in the readme.
Ok thank you, i will test this tomorrow :slightly_smiling_face:
- Angular: i tried starting the project but i got an error
Try to delete node_modules folder and package-lock.json file and run npm install again, this can solve this error.
Thank you @kaidohallik i will try this later this day and i will keep you updated :slightly_smiling_face:
I tried both solution for jhipster-bom and node_modules and works fine ( needed to upgrade node version too for angular ), i got another issue when trying to link the generator-jhipster

i will check it out and continue tomorrow
Never mind i upgraded the node and it works now

@medamineziraoui Do you still have issues with your setup?
Hello no i don't have setups issues thx to your advice guys so thank you, i wasn't able to work fixe the issue those pass days but i will this weekend.
Most helpful comment
Never mind i upgraded the node and it works now
