🚚(frontend) rename useTransRole to useTrans
We rename useTransRole to useTrans to make it more general and reusable. It will be used for all reusable doc translation.
This commit is contained in:
@@ -1 +1 @@
|
||||
export * from './useTransRole';
|
||||
export * from './useTrans';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Role } from '../types';
|
||||
|
||||
export const useTransRole = () => {
|
||||
export const useTrans = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const translatedRoles = {
|
||||
@@ -12,9 +12,10 @@ export const useTransRole = () => {
|
||||
[Role.EDITOR]: t('Editor'),
|
||||
};
|
||||
|
||||
const transRole = (role: Role) => {
|
||||
return translatedRoles[role];
|
||||
return {
|
||||
transRole: (role: Role) => {
|
||||
return translatedRoles[role];
|
||||
},
|
||||
untitledDocument: t('Untitled document'),
|
||||
};
|
||||
|
||||
return transRole;
|
||||
};
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
currentDocRole,
|
||||
isDocsOrdering,
|
||||
useDocs,
|
||||
useTransRole,
|
||||
useTrans,
|
||||
} from '@/features/docs/doc-management';
|
||||
import { useDate } from '@/hook/';
|
||||
|
||||
@@ -48,7 +48,7 @@ function formatSortModel(sortModel: SortModelItem): DocsOrdering | undefined {
|
||||
|
||||
export const DocsGrid = () => {
|
||||
const { colorsTokens } = useCunninghamTheme();
|
||||
const transRole = useTransRole();
|
||||
const { transRole } = useTrans();
|
||||
const { t } = useTranslation();
|
||||
const { formatDate } = useDate();
|
||||
const pagination = usePagination({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Select } from '@openfun/cunningham-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Role, useTransRole } from '@/features/docs/doc-management';
|
||||
import { Role, useTrans } from '@/features/docs/doc-management';
|
||||
|
||||
interface ChooseRoleProps {
|
||||
currentRole: Role;
|
||||
@@ -19,7 +19,7 @@ export const ChooseRole = ({
|
||||
label,
|
||||
}: ChooseRoleProps) => {
|
||||
const { t } = useTranslation();
|
||||
const transRole = useTransRole();
|
||||
const { transRole } = useTrans();
|
||||
|
||||
return (
|
||||
<Select
|
||||
|
||||
Reference in New Issue
Block a user