Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/views/NotFound.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</template>

<script>
import { updateLocale } from 'theme/utils/i18n-utils';
import GenericError from 'theme/components/GenericError.vue';
import AppStore from 'docc-render/stores/AppStore';

Expand All @@ -24,5 +25,13 @@ export default {
created() {
AppStore.setAllLocalesAreAvailable();
},
beforeRouteEnter(to, from, next) {
next((vm) => {
updateLocale(to.params.locale, vm);
});
},
beforeRouteUpdate(to) {
updateLocale(to.params.locale, this);
},
};
</script>
9 changes: 9 additions & 0 deletions src/views/ServerError.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</template>

<script>
import { updateLocale } from 'theme/utils/i18n-utils';
import GenericError from 'theme/components/GenericError.vue';
import AppStore from 'docc-render/stores/AppStore';

Expand All @@ -22,5 +23,13 @@ export default {
created() {
AppStore.setAllLocalesAreAvailable();
},
beforeRouteEnter(to, from, next) {
next((vm) => {
updateLocale(to.params.locale, vm);
});
},
beforeRouteUpdate(to) {
updateLocale(to.params.locale, this);
},
};
</script>
3 changes: 3 additions & 0 deletions src/views/Topic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
</template>

<script>
import { updateLocale } from 'theme/utils/i18n-utils';
import {
fetchDataForRouteEnter,
shouldFetchDataForRouteUpdate,
Expand Down Expand Up @@ -80,13 +81,15 @@ export default {
return;
}
fetchDataForRouteEnter(to, from, next).then(data => next((vm) => {
updateLocale(to.params.locale, vm);
vm.topicData = data; // eslint-disable-line no-param-reassign
})).catch(next);
},
beforeRouteUpdate(to, from, next) {
if (shouldFetchDataForRouteUpdate(to, from)) {
fetchDataForRouteEnter(to, from, next).then((data) => {
this.topicData = data;
updateLocale(to.params.locale, this);
next();
}).catch(next);
} else {
Expand Down
3 changes: 3 additions & 0 deletions src/views/TutorialsOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</template>

<script>
import { updateLocale } from 'theme/utils/i18n-utils';
import {
fetchDataForRouteEnter,
shouldFetchDataForRouteUpdate,
Expand Down Expand Up @@ -54,13 +55,15 @@ export default {
}

fetchDataForRouteEnter(to, from, next).then(data => next((vm) => {
updateLocale(to.params.locale, vm);
vm.topicData = data; // eslint-disable-line no-param-reassign
})).catch(next);
},
beforeRouteUpdate(to, from, next) {
if (shouldFetchDataForRouteUpdate(to, from)) {
fetchDataForRouteEnter(to, from, next).then((data) => {
this.topicData = data;
updateLocale(to.params.locale, this);
next();
}).catch(next);
} else {
Expand Down
1 change: 1 addition & 0 deletions tests/unit/setup-utils/SwiftDocCRenderRouter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import FetchError from 'docc-render/errors/FetchError';

jest.mock('docc-render/utils/theme-settings', () => ({
baseUrl: '/',
getSetting: jest.fn(),
}));

const mockInstance = {
Expand Down