Skip to content

Commit

Permalink
Merge pull request #92 from entando/ENG-4201
Browse files Browse the repository at this point in the history
ENG-4201 Use default language instead of en for page titles
  • Loading branch information
raxkaynan authored Sep 23, 2022
2 parents a10afc9 + 11d2a68 commit 2098b00
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/env-bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ const ALL_TYPES = [
'language',
];

var coreBaseApi, componentManagerApi, clientId, clientSecret, apiUrlTable;
var coreBaseApi, componentManagerApi, clientId, clientSecret, apiUrlTable, defaultLang;

const componentDetailExtractors = {
page: (components) =>
components.map((c) => {
return { value: c.code, name: `${c.titles.en} (${c.code})` };
return { value: c.code, name: `${c.titles[defaultLang]} (${c.code})` };
}),
pageModel: (components) =>
components.map((c) => {
Expand Down Expand Up @@ -865,6 +865,15 @@ const getToken = async function () {
return res.data.access_token;
};

async function getDefaultLang() {
const response = await axios.get(apiUrlTable.language, {
withCredentials: true,
headers: { Authorization: `Bearer ${token}` },
});

return response.data.payload.find(lang => lang.isDefault).code;
}

async function getComponents (type, componentsToFetch) {
// Check if exists in cache
if (hasProperty(componentCache, type)) {
Expand Down Expand Up @@ -1223,7 +1232,7 @@ async function setupEnvironment (options) {

token = await getToken();


defaultLang = await getDefaultLang();
}

async function interactiveSession () {
Expand Down

0 comments on commit 2098b00

Please sign in to comment.