Comments (5)
I'm glad you were able to solve it somehow.. I'm not familiar with those libraries.
Looking forward to having top level await
ASAP in Node =)
from remix-forms.
We don't use remix-i18next
or react-i18next
and TBH I wouldn't use it unless I had a really good reason.
Translating strings require only a pure function:
declare function t(i: string): string
It is not something that should depend on a component. There'll be plenty of strings coming from the server that should not depend on being in a hook... flash messages, for instance, will need to be set on the server and they'll need translation.
What you can do is using the i18next
library though. Or any other library / custom function that conforms (i: string): string
IMHO
from remix-forms.
What I'm really looking after is any function that can implement:
const schema = z.object({
name: z.string().min(3, t('forms.name')),
});
from remix-forms.
My workaround ended up being:
const schema = z.object({
name: z.string().min(3, 'user-profile:name-required-and-constraints'),
});
where the component then grabs the value like this:
const Error = ({ children, ...props }: JSX.IntrinsicElements['div']) => {
const { t } = useTranslation();
return (
<p className="mt-2 text-sm text-red-600" {...props}>
{typeof children === 'string' ? t(children, children) : children}
</p>
);
};
@gustavoguichard thanks for the suggestion. The problem with Remix-i18next's i18next
is, that it only offers i18next.getFixedT
, which returns a promise and is therefore not usable for defining the schema
.
from remix-forms.
hey, I've used this:
labels={Object.fromEntries(
Object.keys(schema.shape).map((key) => [key, t(key)])
)}
to localize the labels in case its helpful to others or worth documenting (I believe i18n is worth documenting!)
localizing errors is still on my todo list
from remix-forms.
Related Issues (20)
- field param of useFieldArray not being updated in real-time and out of date when passed to modal HOT 3
- pendingButtonLabel should default to the value of buttonLabel HOT 1
- 1.6.3: Uncaught (in promise) Error: Cannot submit element that is not <form>, <button>, or <input type="submit|image"> HOT 1
- Attach errors to Fields that are dynamically generated? HOT 2
- Inconsistent display of selected option in select control HOT 4
- Custom Component typings HOT 2
- Error: Cannot submit element that is not <form>, <button>, or <input type="submit|image"> HOT 1
- Multiple Checkboxes HOT 3
- Define Input type through fieldTypes HOT 5
- Bring `errorMessagesForSchema` from `domain-functions` to this library HOT 1
- form with mode="onChange" button flashes when it hydrates HOT 2
- Could not resolve "@deepkit/type" HOT 3
- Overriding fields HOT 2
- <Field hidden /> is not passing `type="hidden"` to its input
- Validation error not shown when field is an array
- Can't trigger onSubmit from Form-component HOT 6
- Handle `z.object` HOT 1
- Can remix-forms function within a PWA / client side only context? HOT 4
- Zod schema array of objects HOT 1
- Remix forms site example no longer maintained? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remix-forms.