Skip to content

Translations respect language of user profile #1337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 16, 2025
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
2 changes: 1 addition & 1 deletion assets/build/api/docs.jsonopenapi.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const initialState: UserInformation = {
isAdmin: false,
classes: [],
docTypes: [],
language: 'en',
activePerspective: 0,
perspectives: [],
language: 'en',
dateTimeLocale: '',
welcomeScreen: false,
memorizeTabs: false,
Expand Down
20 changes: 11 additions & 9 deletions assets/js/src/core/modules/app/app-loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const AppLoader = (props: IAppLoaderProps): React.JSX.Element => {
dispatch(setUser(data))
}
})
.catch(() => {})
.catch(() => { })

return await userFetcher
}
Expand All @@ -79,7 +79,7 @@ export const AppLoader = (props: IAppLoaderProps): React.JSX.Element => {
dispatch(setSettings(data))
}
})
.catch(() => {})
.catch(() => { })

return await settingsFetcher
}
Expand All @@ -91,10 +91,12 @@ export const AppLoader = (props: IAppLoaderProps): React.JSX.Element => {
}

async function loadTranslations (): Promise<any> {
await translations({ translation: { locale: 'en', keys: [] } })
const user = selectCurrentUser(store.getState())
await translations({ translation: { locale: user.language, keys: [], useFallback: true } })
.unwrap()
.then(response => {
i18n.addResourceBundle('en', 'translation', response.keys ?? [], true, true)
i18n.addResourceBundle(user.language, 'translation', response.keys ?? [], true, true)
void i18n.changeLanguage(user.language)
})
.catch(() => {
trackError(new GeneralError('Error loading translations'))
Expand All @@ -106,19 +108,19 @@ export const AppLoader = (props: IAppLoaderProps): React.JSX.Element => {

if (isSuccessInitSetting === true) {
Promise.allSettled([
initActivePerspective()
initActivePerspective(),
loadTranslations()
]).then(() => {
}).catch(() => {})
}).catch(() => { })
}
}

useEffect(() => {
Promise.all([
initLoadUser(),
loadTranslations()
initLoadUser()
]).then(() => {
setIsLoading(false)
}).catch(() => {})
}).catch(() => { })
}, [])

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/src/core/modules/auth/user/user-slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const initialState: UserInformation = {
isAdmin: false,
classes: [],
docTypes: [],
language: 'en',
activePerspective: 0,
perspectives: [],
language: 'en',
dateTimeLocale: '',
welcomeScreen: false,
memorizeTabs: false,
Expand Down
56 changes: 46 additions & 10 deletions assets/js/src/core/modules/document/document-api-slice.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ const injectedRtkApi = api
})
.injectEndpoints({
endpoints: (build) => ({
documentAdd: build.mutation<DocumentAddApiResponse, DocumentAddApiArg>({
query: (queryArg) => ({
url: `/pimcore-studio/api/documents/add/${queryArg.parentId}`,
method: "POST",
body: queryArg.documentAddParameters,
}),
invalidatesTags: ["Documents"],
}),
documentsListAvailableSites: build.query<
DocumentsListAvailableSitesApiResponse,
DocumentsListAvailableSitesApiArg
Expand Down Expand Up @@ -48,6 +56,15 @@ const injectedRtkApi = api
overrideExisting: false,
});
export { injectedRtkApi as api };
export type DocumentAddApiResponse = /** status 200 ID of added document */ {
/** ID of created document element */
id: number;
};
export type DocumentAddApiArg = {
/** ParentId of the document */
parentId: number;
documentAddParameters: DocumentAdd;
};
export type DocumentsListAvailableSitesApiResponse = /** status 200 List of available sites */ {
items: Site[];
};
Expand Down Expand Up @@ -96,6 +113,34 @@ export type DocumentGetTreeApiArg = {
/** Include all descendants in the result. */
pathIncludeDescendants?: boolean;
};
export type Error = {
/** Message */
message: string;
};
export type DevError = {
/** Message */
message: string;
/** Details */
details: string;
};
export type DocumentAdd = {
/** Key */
key: string;
/** Type */
type: string;
/** Title */
title: any;
/** Navigation name */
navigationName: any;
/** Document type ID */
docTypeId: any;
/** Id of the base document for new translation */
translationsSourceId: any;
/** Document language when adding a translation */
language: any;
/** Id of the base document for content */
inheritanceSourceId: any;
};
export type Site = {
/** AdditionalAttributes */
additionalAttributes?: {
Expand All @@ -112,16 +157,6 @@ export type Site = {
/** Root path */
rootPath?: any;
};
export type Error = {
/** Message */
message: string;
};
export type DevError = {
/** Message */
message: string;
/** Details */
details: string;
};
export type ElementIcon = {
/** Icon type */
type: "name" | "path";
Expand Down Expand Up @@ -299,6 +334,7 @@ export type Snippet = Document & {
staticGeneratorLifetime?: number;
};
export const {
useDocumentAddMutation,
useDocumentsListAvailableSitesQuery,
useDocumentGetByIdQuery,
useDocumentPageStreamPreviewQuery,
Expand Down
12 changes: 0 additions & 12 deletions public/build/5c175c30-f135-4352-abe1-36fcb47027c8/entrypoints.json

This file was deleted.

14 changes: 0 additions & 14 deletions public/build/5c175c30-f135-4352-abe1-36fcb47027c8/manifest.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"entrypoints": {
"vendor": {
"js": [
"/bundles/pimcorestudioui/build/80f3ca92-2343-436f-ad38-339f72f9962c/vendor.js"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bundles/pimcorestudioui/build/80f3ca92-2343-436f-ad38-339f72f9962c/vendor.js": "/bundles/pimcorestudioui/build/80f3ca92-2343-436f-ad38-339f72f9962c/vendor.js"
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions public/build/b5815405-f353-4d8e-aa34-1ae5768b226e/entrypoints.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"entrypoints": {
"core-dll": {
"css": [
"/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/core-dll.css"
],
"js": [
"/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/core-dll.js"
]
}
}
}
14 changes: 14 additions & 0 deletions public/build/b5815405-f353-4d8e-aa34-1ae5768b226e/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"bundles/pimcorestudioui/b5815405-f353-4d8e-aa34-1ae5768b226e/core-dll.css": "/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/core-dll.css",
"bundles/pimcorestudioui/b5815405-f353-4d8e-aa34-1ae5768b226e/core-dll.js": "/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/core-dll.js",
"bundles/pimcorestudioui/b5815405-f353-4d8e-aa34-1ae5768b226e/105.js": "/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/105.js",
"bundles/pimcorestudioui/b5815405-f353-4d8e-aa34-1ae5768b226e/fonts/Lato-Light.ttf": "/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/fonts/Lato-Light.c7400fca.ttf",
"bundles/pimcorestudioui/b5815405-f353-4d8e-aa34-1ae5768b226e/fonts/Lato-Regular.ttf": "/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/fonts/Lato-Regular.9d883d54.ttf",
"bundles/pimcorestudioui/b5815405-f353-4d8e-aa34-1ae5768b226e/fonts/Lato-Bold.ttf": "/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/fonts/Lato-Bold.636be8de.ttf",
"bundles/pimcorestudioui/b5815405-f353-4d8e-aa34-1ae5768b226e/images/spritesheet.svg": "/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/images/spritesheet.a4e0eb7a.svg",
"bundles/pimcorestudioui/b5815405-f353-4d8e-aa34-1ae5768b226e/images/spritesheet-2x.png": "/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/images/spritesheet-2x.7ea3a6d4.png",
"bundles/pimcorestudioui/b5815405-f353-4d8e-aa34-1ae5768b226e/images/spritesheet.png": "/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/images/spritesheet.ef32ea2b.png",
"bundles/pimcorestudioui/b5815405-f353-4d8e-aa34-1ae5768b226e/images/marker-icon.png": "/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/images/marker-icon.2b3e1faf.png",
"bundles/pimcorestudioui/b5815405-f353-4d8e-aa34-1ae5768b226e/images/layers-2x.png": "/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/images/layers-2x.8f2c4d11.png",
"bundles/pimcorestudioui/b5815405-f353-4d8e-aa34-1ae5768b226e/images/layers.png": "/bundles/pimcorestudioui/build/b5815405-f353-4d8e-aa34-1ae5768b226e/images/layers.416d9136.png"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"entrypoints": {
"main": {
"js": [
"/bundles/pimcorestudioui/build/ea89a32b-d610-41f2-986e-caa6893c8340/main.js"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"bundles/pimcorestudioui/build/ea89a32b-d610-41f2-986e-caa6893c8340/main.js": "/bundles/pimcorestudioui/build/ea89a32b-d610-41f2-986e-caa6893c8340/main.js"
}