Localized assets
If you want to find out which asset system your project uses and which section of this document applies to you, click here.
#Hygraph Asset Management
Our asset system lets you create a localizations by providing as fileName
(optional) and uploadUrl
. You can use the createAsset
mutation and create the localization simultaneously, or use updateAsset
and add a localization to an existing asset.
If you don't pass a fileName
, the system uses the file name of the file you provide - via URL or local file.
If you pass a fileName
, it overwrites the name of the file you provide.
The following example shows the URL upload of an asset along with its localized content:
mutation test {createAsset(data: {uploadUrl: "<UPLOAD_URL>"localizations:{create: {locale: dedata:{uploadUrl: "<LOCALE_UPLOAD_URL>"}}}}) {idurllocalizations {idurl}}}
This other example updates an existing asset entry, adding the de
localization:
mutation test {updateAsset(where: {id: "<ASSET_ID>"}data: {localizations: {create: {locale: de,data: {uploadUrl: "<LOCALE_UPLOAD_URL>"}}}}) {idlocaleurllocalizations {urllocale}}}
For the action of creation of localized assets to work, your project configuration must already have the locale configured.
Learn more about mutating localized content.
#Legacy asset system
Since assets are localized by default, you can upload a file for your project locales.
You can do this from the UI: Simply navigate to Assets and access the edit view of your asset entry.
Click the eye icon next to your localization to ensure the Upload
button is visible.
Asset localization - Legacy asset system
Localizations only display on the sidebar if you've previously configured them in your project settings.
#Localize assets in the UI
You can also localize assets using the UI. Check out this document to learn more.