Skip to content

Commit

Permalink
Merge pull request #343 from matematikk-mooc/KURSP-914-apply-selected…
Browse files Browse the repository at this point in the history
…-languaga-module-selector

KURSP-914 get the language that is selected and use that to translate label
  • Loading branch information
ThereseRingPersen authored Nov 6, 2023
2 parents 8b07995 + c153d2b commit b0459ce
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/vue/components/course-modules/CourseModule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<li v-for="course in nodes" :key="course.id">
<TreeView
:type="course.type"
:label="extractLabelForSelectedLanguage(course.label, 'nb')"
:label="extractLabelForSelectedLanguage(course.label,getSelectedLanguage())"
:id="course.id"
:url="course.url? course.url : ''"
:nodes="course.nodes"
Expand All @@ -46,10 +46,10 @@
</template>

<script setup>
import { ref, computed, defineProps, defineEmits } from 'vue';
import { ref, computed, defineProps, defineEmits} from 'vue';
import Icon from '../icon/Icon.vue';
import TreeView from '../tree-view/TreeView.vue';
import { extractLabelForSelectedLanguage } from '../../utils/lang-utils';
import { extractLabelForSelectedLanguage, getSelectedLanguage } from '../../utils/lang-utils';
const props = defineProps({
Expand All @@ -61,7 +61,6 @@ const props = defineProps({
});
const emits = defineEmits(['toggleActiveModule']);
const collapsed = ref(true);
const selectedNode = ref(-1);
Expand Down
5 changes: 3 additions & 2 deletions src/vue/components/course-modules/CourseModules.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
>
<CourseModule
:type="module.type"
:label="extractLabelForSelectedLanguage(module.label, 'nb')"
:label="extractLabelForSelectedLanguage(module.label,getSelectedLanguage())"
:id="module.id"
:nodes="module.nodes"
:isActive="isActiveModule(module.id)"
Expand All @@ -29,7 +29,7 @@
import { defineProps, ref } from 'vue';
import Icon from '../icon/Icon.vue';
import CourseModule from './CourseModule.vue';
import { extractLabelForSelectedLanguage } from '../../utils/lang-utils';
import { extractLabelForSelectedLanguage, getSelectedLanguage } from '../../utils/lang-utils';
const props = defineProps({
Expand All @@ -40,6 +40,7 @@ const treestructure = props.nodes; // Assign nodes prop to treestructure
const selectedNode = ref(-1);
const toggleActiveModule = ({moduleId, isOpen}) => {
if (selectedNode.value === moduleId) {
if (isOpen) {
Expand Down
4 changes: 2 additions & 2 deletions src/vue/components/tree-view/TreeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<li v-for="node in nodes" :key="node.id" class="tree-node__child-nodes__node">
<TreeView
:type="node.type"
:label="extractLabelForSelectedLanguage(node.label, 'nb')"
:label="extractLabelForSelectedLanguage(node.label, getSelectedLanguage())"
:id="node.id"
:nodes="node.nodes"
:url = "node.url? node.url : ''"
Expand All @@ -41,7 +41,7 @@
<script setup>
import { ref, computed, defineProps, defineEmits } from 'vue';
import Icon from '../icon/Icon.vue';
import { extractLabelForSelectedLanguage } from '../../utils/lang-utils';
import { extractLabelForSelectedLanguage, getSelectedLanguage } from '../../utils/lang-utils';
const props = defineProps({
type: String,
Expand Down
6 changes: 6 additions & 0 deletions src/vue/utils/lang-utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import multilanguage from "../../js/3party/multilanguage";
/**
* Cleans a string to extract content based on a specified language code.
* @param {string} label - The input string containing language-specific content.
Expand Down Expand Up @@ -32,3 +33,8 @@ export function extractLabelForSelectedLanguage(label, param) {
// If there's no language codes or matches, return the label as is.
return label;
}

export function getSelectedLanguage() {
return multilanguage.getLanguageParameter();

}

0 comments on commit b0459ce

Please sign in to comment.