MCPcopy
hub / github.com/marmelab/react-admin / translate

Function translate

packages/ra-ui-materialui/src/form/SimpleForm.stories.tsx:155–179  ·  view source on GitHub ↗
(x, options)

Source from the content-addressed store, hash-verified

153);
154
155const translate = (x, options) => {
156 switch (x) {
157 case 'resources.books.name':
158 return 'Books';
159 case 'ra.page.edit':
160 return 'Edit';
161 case 'resources.books.fields.title':
162 return 'Title';
163 case 'resources.books.fields.author':
164 return 'Author';
165 case 'resources.books.fields.year':
166 return 'Year';
167 case 'ra.action.save':
168 return 'Save';
169 case 'ra.action.delete':
170 return 'Delete';
171 case 'ra.validation.required.author':
172 return 'The author is required';
173 case 'ra.validation.maxValue':
174 return `The year must be less than ${options.max}`;
175 default:
176 console.warn(`Missing translation for key '${x}'`);
177 return options?._ ?? x;
178 }
179};
180
181const validate = values => {
182 const errors = {} as any;

Callers 15

index.tsFile · 0.85
UserMenuFunction · 0.85
PageTitleFunction · 0.85
ConfirmFunction · 0.85
SidebarToggleButtonFunction · 0.85
ErrorFunction · 0.85
NotificationFunction · 0.85
AccessDeniedFunction · 0.85
renderMenuItemFunction · 0.85
MenuItemLink.tsxFile · 0.85

Calls

no outgoing calls

Tested by 2

ComponentFunction · 0.68
ComponentFunction · 0.68