-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feature: Added the ability to localize RJSF internal strings #3460
feature: Added the ability to localize RJSF internal strings #3460
Conversation
True fix for rjsf-team#205 to support localizing the internal strings in @rjsf - In `@rjsf/utils`, added `TranslatableString` enum and `englishStringTranslator()` and `replaceStringParameters()` to support localization - Also updated the `Registry` type to add the `translateString` function - Added 100% unit testing for the new functions - In `@rjsf/core`, added a new `translateString` prop to `FormProps` as well as using that prop in the `registry` if provided - Updated the `getDefaultRegistry()` to set `translateString` to `englishStringTranslator` - Updated `ArrayField`, `BooleanField`, `MultiSchemaField`, `ObjectField`, `SchemaField`, `AddButton`, `IconButton`s, `ErrorList`, `WrapIfAdditionalTemplate` and `AltDateWidget` and `FileWidget` to use `translateString` - Added the `markdown-to-jsx` to support localizing the `UnsupportedField` - In all the themes, updated `ErrorList`, `IconButton`s, `AddButton`, `WrapIfAdditionalTemplate` and where applicable `AltDateWidget` to use `translateString` from the registry - Updated the snapshots for `UnsupportedField` based on the cleaned up translation formatting - In `@rjsf/chakra-ui`, updated `TextAreaWidget` and `UpDownWidget` to switch `??` syntax to `||` - In `@rjsf/semantic-ui`, updated the `FieldErrorTemplate` and `FieldHelpTemplate` to use the `errorId()` and `helpId()` functions - Updated the `utility-functions` docs for the enums and the new functions - Updated the `form-props` docs to describe the new `translateString` prop - Updated the `CHANGELOG` accordingly
d7919a8
to
0b20e43
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Couple of notes--not sure if they are real issues. See comments before merging.
Documented support for markdown and html as well
Minor fixes
small doc fix
More documentation updates
Revert change
Hey @heath-freenome thank you very much for adding this improvement into library! |
Reasons for making this change
True fix for #205 to support localizing the internal strings in @rjsf
@rjsf/utils
, addedTranslatableString
enum andenglishStringTranslator()
andreplaceStringParameters()
to support localizationRegistry
type to add thetranslateString
function@rjsf/core
, added a newtranslateString
prop toFormProps
as well as using that prop in theregistry
if providedgetDefaultRegistry()
to settranslateString
toenglishStringTranslator
ArrayField
,BooleanField
,MultiSchemaField
,ObjectField
,SchemaField
,AddButton
,IconButton
s,ErrorList
,WrapIfAdditionalTemplate
andAltDateWidget
andFileWidget
to usetranslateString
markdown-to-jsx
to support localizing theUnsupportedField
ErrorList
,IconButton
s,AddButton
,WrapIfAdditionalTemplate
and where applicableAltDateWidget
to usetranslateString
from the registryUnsupportedField
based on the cleaned up translation formatting@rjsf/semantic-ui
, updated theFieldErrorTemplate
andFieldHelpTemplate
to use theerrorId()
andhelpId()
functionsutility-functions
docs for the enums and the new functionsform-props
docs to describe the newtranslateString
propCHANGELOG
accordinglyChecklist
npm run test:update
to update snapshots, if needed.