Conversation
|
| nextAppRouter.localize({ | ||
| moduleName: "locale", | ||
| segment: "locale", | ||
| translations: "translations", | ||
| }), |
There was a problem hiding this comment.
@isakgb this means that this router is not in page.val.ts, but the module names are the locale. In addtion: the locale segment is "locale" (and must be an actual locale).
| "en-us": "English", | ||
| "nb-no": "Norwegian", | ||
| "translation-is-available-in": | ||
| "This blog is also available in the following languages:", |
There was a problem hiding this comment.
@isakgb This is useful if you need translations that are "by field".
|
We're now thinking that the initial version will support a The UI will have a filter option in the nav menu (we're not sure about this yet), where the current locale be selected. Selecting a locale will filter across the entire selection. ImplementationAll schemas will have a Later we think we will want to follow up with the following features. TranslationsNot sure about this yet, but we could add a translation property to locale as well. We could even extend this with a way to store the translations. An alternative to the approach above would be to have a "translation key" or some id that indicates that something is translate-able. We need to consider how the "translationsVal" would work as well. For records, it would be logical to create an entry, where the key of a source record maps to a record of target keys by language tag. For other types than record, it is less clear what would be practical. We could do source paths, but that means user will not be able to easily understand + means we need to provide a utility to fetch something based on a module path, which, since it will potentially have to load any type of module, breaks a bit with how we usually do things ( because we can't type things). Yet another way to do this is to do: Field level translationsTo enable "field level" translation, we will add the following features:
const localizedSchema = s.record(s.languages(["en_us", "nb_no"], { optional: ["fr_fr"]})), s.object({ ... }))We'll follow up with more details about how we handle routers wrt localization. Maybe we should add an optional way to do schemas per segments in a router: s.record(...).router(nextAppRouter(), { segments: { country: s.languages(["en_us", "fr_fr"]) }})AppendixThese are the discarded alternatiev representations: .i18n on object with language tagsconst localizedSchema = s.object({
en_US: s.string(),
fr_FR: s.string().nullable(),
}).i18n()This will be means that each of the properties maps to a locale. The keys must be valid language tags. Alternative object representationWe considered something like this: const localizedSchema = s.object.i18n(s.string(), ["en_US"], ["fr_FR"])But decided against it, since we want to make it easy to discern the shape of Val data. |
272f3ac to
8d6daf7
Compare
No description provided.