Translate Functions are the helper functions which you can use to translate your application.
On the fronted they can be used with useTranslation hook. On the backend they are injected to any AdminBro instance and ActionContext.
Members
# translateAction
Translates all actions, to be more specific - their labels.
By default, it looks for a translation key in
resource.{resourceId}.actions.{actionName}
, when it doesn't find
that, the lookup is moved to actions.{actionName}
.
Finally, when that also fails, it returns startCase of the action name.
# translateButton
Translates all buttons.
By default, it looks for a translation key in
resource.{resourceId}.buttons.{actionName}
, when it doesn't find
that, the lookup is moved to buttons.{actionName}
.
Finally, when that also fails, it returns startCase of the given button name.
# translateLabel
Translates all labels. Most of all all resource names are treated as labels.
Also, labels are texts in the user interface which cannot be recognized
as any other type.
By default, it looks for a translation key in
resource.{resourceId}.labels.{actionName}
, when it doesn't find
that, the lookup is moved to labels.{actionName}
.
Finally, when that also fails, it returns startCase of the given label.
# translateMessage
Translates all the messages in the application.
By default, it looks for a translation key in
resource.{resourceId}.messages.{messageName}
, when it doesn't find
that, the lookup is moved to messages.{messageName}
.
Finally, when that also fails, it returns startCase of the given message name.
# translateProperty
Translates all the property names.
By default, it looks for a translation key in
resource.{resourceId}.properties.{propertyPath}
, when it doesn't find
that, the lookup is moved to properties.{propertyPath}
. When that fails,
it returns startCase of the given property name.
What is important here is that you can put nested property as well, In that case you have to pass dotted path:
{
properties: {
parent: 'parent property',
'parent.nested': 'nested property'
}
}
Type Definitions
# TranslateFunction(key, resourceIdopt, optionsopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
string | kwy which should be translated in a given namespace |
|
resourceId |
string | TOptions |
<optional> |
Optional resourceId or Translate options |
options |
TOptions |
<optional> |