-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2406 from Roksnet/feature/XRDDEV-2728
feat: XRDDEV-2728 Add language switching to the UI of Central and Security Server
- Loading branch information
Showing
12 changed files
with
472 additions
and
35 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
src/central-server/admin-service/ui/src/components/layout/LanguageDropdown.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<!-- | ||
The MIT License | ||
|
||
Copyright (c) 2019- Nordic Institute for Interoperability Solutions (NIIS) | ||
Copyright (c) 2018 Estonian Information System Authority (RIA), | ||
Nordic Institute for Interoperability Solutions (NIIS), Population Register Centre (VRK) | ||
Copyright (c) 2015-2017 Estonian Information System Authority (RIA), Population Register Centre (VRK) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
--> | ||
<template> | ||
<div class="language-changer"> | ||
<v-menu location="bottom"> | ||
<template #activator="{ props }"> | ||
<v-btn | ||
class="no-uppercase" | ||
data-test="language-button" | ||
v-bind="props" | ||
variant="text" | ||
> | ||
<strong>{{ currentLanguage }}</strong> | ||
<v-icon icon="mdi-chevron-down" /> | ||
</v-btn> | ||
</template> | ||
|
||
<v-list> | ||
<v-list-item | ||
v-for="language in languages" | ||
:key="language" | ||
:active="language === currentLanguage" | ||
data-test="language-list-tile" | ||
@click="switchLanguage(language)" | ||
> | ||
{{ language }} | ||
</v-list-item> | ||
</v-list> | ||
</v-menu> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue'; | ||
import { mapActions } from 'pinia'; | ||
import { useLanguage } from '@/store/modules/language'; | ||
import { availableLanguages } from '@/plugins/i18n'; | ||
|
||
export default defineComponent({ | ||
computed: { | ||
// Using a computed property for the current language for reactivity | ||
currentLanguage() { | ||
return this.$i18n.locale; | ||
}, | ||
languages() { | ||
return availableLanguages; | ||
}, | ||
}, | ||
methods: { | ||
...mapActions(useLanguage, ['changeLanguage']), | ||
switchLanguage(language: string): void { | ||
if (language !== this.currentLanguage) { | ||
this.changeLanguage(language); | ||
} | ||
}, | ||
}, | ||
}); | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.language-changer { | ||
margin-left: auto; | ||
display: flex; | ||
align-items: center; | ||
|
||
.no-uppercase { | ||
text-transform: none; | ||
font-weight: 600; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/central-server/admin-service/ui/src/store/modules/language.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2019- Nordic Institute for Interoperability Solutions (NIIS) | ||
* Copyright (c) 2018 Estonian Information System Authority (RIA), | ||
* Nordic Institute for Interoperability Solutions (NIIS), Population Register Centre (VRK) | ||
* Copyright (c) 2015-2017 Estonian Information System Authority (RIA), Population Register Centre (VRK) | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
import { defineStore } from 'pinia'; | ||
import { setLanguage } from '@/plugins/i18n'; | ||
|
||
export const useLanguage = defineStore('language', { | ||
state: () => ({ | ||
language: import.meta.env.VITE_I18N_LOCALE || ('en' as string), | ||
}), | ||
|
||
persist: { | ||
storage: localStorage, | ||
}, | ||
|
||
getters: { | ||
getLanguage(state): string { | ||
return state.language; | ||
}, | ||
}, | ||
|
||
actions: { | ||
async changeLanguage(language: string) { | ||
this.language = language; | ||
await setLanguage(language); | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.