You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| **slot** | `enum` | The position where the fab will be placed. Valid values: `PAGE_END`, `BOTTOM_LEFT`. | [optional] default to `PAGE_END`. |
253
253
| **label** | `String` | A name for your action button. | required |
254
+
| **labelKey** | `String` | Translation key for the label. If provided, will be used instead of label when translations are available. | optional |
254
255
| **icon** | `String`<br>`React.ReactElement`<br>`SVG image icon`<br>`HTML image icon` | An icon for your floating button. Recommended to use **filled** icons from the [Material Design library](https://fonts.google.com/icons) | optional |
255
256
| **showLabel** | `Boolean` | To display the label next to your icon. | optional |
256
257
| **size** | `'small'`<br>`'medium'`<br>`'large'` | A name for your action button. | [optional] default to `'medium'` |
257
258
| **color** | `'default'`<br>`'error'`<br>`'info'`<br>`'inherit'`<br>`'primary'`<br>`'secondary'`<br>`'success'`<br>`'warning'` | The color of the component. It supports both default and custom theme colors, which can be added as shown in the [palette customization guide](https://mui.com/material-ui/customization/palette/#custom-colors). | [optional] default to `'default'`. |
258
259
| **onClick** | `React.MouseEventHandler` | the action to be performed on `onClick`. | optional |
259
260
| **to** | `String` | Specify an href if the action button should open a internal/external link. | optional |
260
261
| **toolTip** | `String` | The text to appear on hover. | optional |
262
+
| **toolTipKey** | `String` | Translation key for the tooltip. If provided, will be used instead of toolTip when translations are available. | optional |
261
263
| **priority** | `number` | When multiple sub-menu actions are displayed, the button can be prioritized to position either at the top or the bottom. | optional |
262
264
| **visibleOnPaths** | `string[]` | The action button will appear only on the specified paths and will remain hidden on all other paths. | [optional] default to displaying on all paths. |
263
265
| **excludeOnPaths** | `string[]` | The action button will be hidden only on the specified paths and will appear on all other paths. | [optional] default to displaying on all paths. |
264
266
267
+
### Translation Support
268
+
269
+
The Global Floating Action Button plugin supports internationalization (i18n) through translation keys. You can use `labelKey` and `toolTipKey` properties to provide translation keys instead of static text.
270
+
271
+
#### Using Translation Keys in Dynamic Configuration
The plugin automatically registers its translations when loaded. The translation system is built into the plugin configuration and will be available when the plugin is installed.
346
+
347
+
For dynamic plugins, translations are automatically loaded with the plugin. For static installations, the translations are registered through the plugin's `__experimentalTranslations` configuration.
348
+
349
+
#### Built-in Translation Keys
350
+
351
+
The plugin provides built-in translation keys organized under the `fab` namespace:
352
+
353
+
- `fab.create.label`- "Create"
354
+
- `fab.create.tooltip`- "Create entity"
355
+
- `fab.docs.label`- "Docs"
356
+
- `fab.docs.tooltip`- "Documentation"
357
+
- `fab.apis.label`- "APIs"
358
+
- `fab.apis.tooltip`- "API Documentation"
359
+
- `fab.github.label`- "GitHub"
360
+
- `fab.github.tooltip`- "GitHub Repository"
361
+
- `fab.bulkImport.label`- "Bulk Import"
362
+
- `fab.bulkImport.tooltip`- "Register multiple repositories in bulk"
363
+
- `fab.quay.label`- "Quay"
364
+
- `fab.quay.tooltip`- "Quay Container Registry"
365
+
366
+
#### Supported Languages
367
+
368
+
The plugin includes translations for:
369
+
370
+
- **English** (default)
371
+
- **German** (de)
372
+
- **French** (fr)
373
+
- **Spanish** (es)
374
+
375
+
#### How Translation Resolution Works
376
+
377
+
1. If `labelKey` is provided, the plugin will attempt to resolve the translation key
378
+
2. If the translation key is found, it will be used as the label
379
+
3. If the translation key is not found, the plugin will fall back to the `label` property
380
+
4. The same logic applies to `toolTipKey` and `toolTip`
381
+
382
+
This ensures backward compatibility while providing translation support when available.
383
+
384
+
#### Internal Translation Implementation
385
+
386
+
The plugin uses a centralized translation system where:
387
+
388
+
- The `useTranslation()` hook is called in components that render floating action buttons to ensure proper translation context initialization
389
+
- The translation function (`t`) is passed down to child components that need to resolve translation keys
390
+
- This internal architecture prevents infinite re-render loops and ensures stable component rendering
391
+
- All components that use `CustomFab` must provide the translation function as a prop
392
+
393
+
**Note for Developers**: When extending or modifying the plugin components, ensure that the `useTranslation()` hook is called in parent components and the `t` prop is passed to `CustomFab` instances to maintain proper translation functionality and prevent rendering issues.
394
+
265
395
**NOTE**
266
396
267
397
If multiple floating button actions are assigned to the same `Slot`, they will appear as sub-menu options within the floating button.
0 commit comments