The main feature is the ability to localize user content, in other words support multiple languages for, e.g. a movie title or description.
Data Storage
Instead of storing the title field as a String, it will now be stored as an Object of the form {en: 'Die Hard', fr: 'Piège de cristal'}.
The cool thing with GraphQL is that the API can still return a String, meaning you wouldn't have to update any of your front-end code to support multiple languages.
Issues/Questions:
For existing content, should we migrate existing fields in place? Or add a new field (making the schema/forms more complex)?
Internationalizing a Field
For string fields, change type: String to type: getIntlString() in your schema.
Issues/Questions:
How do we handle resolveAs fields? Add a switch in the resolver based on context.locale?
Selecting a Locale
This is still a WIP, but there are currently two ways:
ask for title(locale: 'fr') in your GraphQL query.
set the locale header in your GraphQL query.
Issues/Questions:
How do we let users switch language?
Based on domain (foo.com vs foo.fr)?
Based on query string (foo.com/en vs foo.com/fr)?
How do we save a user's preferred language?
How do we detect the locale during the SSR process?
How do we pick the right locale when sending out emails? Based on which user the email is addressed to?
I've started working on better i18n on the
i18n2
branch: https://github.com/VulcanJS/Vulcan/tree/i18n2Overview
The main feature is the ability to localize user content, in other words support multiple languages for, e.g. a movie title or description.
Data Storage
Instead of storing the
title
field as aString
, it will now be stored as an Object of the form{en: 'Die Hard', fr: 'Piège de cristal'}
.The cool thing with GraphQL is that the API can still return a
String
, meaning you wouldn't have to update any of your front-end code to support multiple languages.Issues/Questions:
Internationalizing a Field
For string fields, change
type: String
totype: getIntlString()
in your schema.Issues/Questions:
resolveAs
fields? Add aswitch
in theresolver
based oncontext.locale
?Selecting a Locale
This is still a WIP, but there are currently two ways:
title(locale: 'fr')
in your GraphQL query.locale
header in your GraphQL query.Issues/Questions:
foo.com
vsfoo.fr
)?foo.com/en
vsfoo.com/fr
)?SmartForm
Works out of the box:
Links
See also previous threads: