Skip to content

Commit

Permalink
feat: content delivery + webhooks (#501)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Cizmar <[email protected]>
  • Loading branch information
stepan662 and JanCizmar authored Nov 24, 2023
1 parent 6f3c755 commit 005c5f0
Show file tree
Hide file tree
Showing 35 changed files with 1,079 additions and 125 deletions.
52 changes: 52 additions & 0 deletions blog/2023-11-23-tolgee-content-delivery.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
slug: tolgee-content-delivery-and-webhooks
title: 'Boost localization automation with Content Delivery and Webhooks'
description: A new content delivery feature allows you to keep your localization files outside of your code. It's a part of our long-term goal to make localization as easy as possible.
authors: [sgranat]
tags: ['tolgee', 'cloud', 'content-delivery', 'webhooks']
image: '/img/blog/content-delivery/content-delivery.webp'
---

Recently, we've received many requests from our users to simplify the update of translations on production, and now we have an answer. Say Hi to Tolgee **Content Delivery**, a fast and reliable way to keep your translations independent of your code! Also introducing **Webhooks** for more automation options.

![Content delivery](/img/blog/content-delivery/content-delivery.webp)

<!-- truncate-->

import { ScreenshotWrapper } from '../platform/shared/_ScreenshotWrapper';

## Load your translations from the cloud

Introducing [Tolgee Content Delivery](/platform/projects_and_organizations/content_delivery), the solution to simplify your translation updates seamlessly. With automatic uploading of localization files to secure cloud storage, your translations remain independent from your codebase, ensuring effortless updates.

### We prioritize Speed and Reliability

Utilizing Content Delivery Network (CDN), Tolgee Content Delivery guarantees **lightning-fast access** to your translated content worldwide. Our caching system ensures reliability and speed, across different geographical locations.

> Because the content is heavily cached, it can take up to 15 minutes to propagate changes.
### Tailored Export Settings

Customize your translation exports effortlessly. Users have the freedom to configure file formats and other export settings, adapting the process to their unique workflows.

<ScreenshotWrapper src="/img/blog/content-delivery/add-content-delivery.png" alt="Add content delivery" />

We also support **deployment to multiple storages** with different settings, if you have different use cases or platforms to target.

> Read more in [Content Delivery documentation](/platform/projects_and_organizations/content_delivery)
## Take automation to a new level (Business and Enterprise plans)

Content delivery is part of our long-term effort to make localization easier and more autonomous. And so with this release, we've added also more low-level options for automation.

### Webhooks

Do you want to react to certain events, that happen in Tolgee Platform? Now you can. Just set up a webhook and Tolgee will tell you what is happening! In the request body, you'll receive an event type (like Translation edit, new comment, new language added, etc.) and you can connect it to your automation.

> Read more in [Webhooks documentation](/platform/projects_and_organizations/webhooks)
### Custom Content Storage

Do you want to have translations in your own protected storage? Easy thing, you can now set this up directly in the Tolgee Platform for each Content Delivery configuration.

[![Join Tolgee Now!](/img/blog/content-delivery/banner-automation.svg)](https://app.tolgee.io/sign_up)
2 changes: 1 addition & 1 deletion blog/authors.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sgranat:
name: Štěpán Granát
title: Co-founder and Frontend Architect
title: Co-founder and CTO
url: https://github.com/stepan662
image_url: /img/blog/profile-photos/stepan.jpeg
description: "Štěpán is a passionate developer responsible for Frontend and SDK development at Tolgee. He's on a mission to make software localization as easy as pie while keeping it smart. 🧠"
Expand Down
28 changes: 23 additions & 5 deletions js-sdk/providing_static_data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,27 @@ slug: providing-static-data

Provide static localization data in production mode or if you want to use it [without Tolgee platform](./usage-without-platform).

## Exporting translation files from Tolgee platform
## Load translations directly from Tolgee

Easiest way is through [`@tolgee/cli`](/tolgee-cli) package:
The easiest way to get to your localization files on production is to set up [Tolgee Content Delivery](/platform/projects_and_organizations/content_delivery) and fetch the translations directly from there.

```ts
import { BackendFetch } from '@tolgee/react';

const tolgee = Tolgee()
...
.use(BackendFetch({ prefix: '<your content storage link>'}))
...
```

## Use localization files directly

Other option is to export localization files Tolgee platform manually and bundle them directly with your application.

### Export with CLI


Install [`@tolgee/cli`](/tolgee-cli) package:

```bash
# install Tolgee cli
Expand All @@ -21,7 +39,7 @@ tolgee login <Your-Personal-Access-Token>
tolgee pull ./i18n
```

## Providing data using dynamic import
### Providing data using dynamic import

To provide your localization data using dynamic import you will need to add providers for every supported language to [`staticData`](./api/core_package/options#staticdata).

Expand All @@ -46,7 +64,7 @@ For some build systems you'll need to use <br/>

Using this approach data will be fetched just when it's needed, so you will save some network traffic.

## Using imported object
### Using imported object

```jsx
import * as localeEn from 'i18n/en.json';
Expand All @@ -70,7 +88,7 @@ const tolgee = Tolgee().init({

Using this approach, all localization data are bundled with your application. Don't use it, if our translations files are large. This approach is useful on SSR, when you need the translations to be available for initial render.

## Providing data using backend plugin
### Providing data using backend plugin

```jsx
import { BackendFetch } from '@tolgee/react';
Expand Down
5 changes: 2 additions & 3 deletions js-sdk/shared/_PreparingForProduction.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
In production mode, you should never use localization data from Tolgee REST API and never leak your API key.
You should use data exported from the Tolgee platform.
To get exported localization files, see [exporting translations](/platform/projects_and_organizations/export).
You should use data exported from the Tolgee platform or use Tolgee Content Delivery load localizations reliably.

Then provide the data via Tolgee configuration options described in [Providing static data](/providing_static_data.mdx).
> Check [Providing static data](/providing_static_data.mdx) section.
115 changes: 115 additions & 0 deletions platform/projects_and_organizations/content_delivery.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
id: content_delivery
title: Content Delivery
sidebar_label: Content Delivery
---

import { ScreenshotWrapper } from '../shared/_ScreenshotWrapper';

Content Delivery will deploy your localization files to reliable and fast cloud storage so you can confidently use them in your application. This way, the updates in your localization files can be reflected without changes to your code or rebuilding the application.

:::info Feature availability
In the free and pay-as-you-go plans, you can use only one content delivery configuration,
and you cannot use custom storage.

Multiple content delivery configurations and custom storages are introduced in the business and enterprise plans. [Upgrade your plan](/pricing) to use this feature.

If you use the self-hosted version, you need to [set up the license](/platform/self_hosting/licensing) to use this feature.
:::

## Setting up the Content Delivery

You can set up Content Delivery in the `Developer settings` section of the Tolgee platform.

1. Go to Developer Settings

<ScreenshotWrapper src="/img/docs/platform/content-delivery/developer-settings.png" alt="Developer Settings" />

2. Click the `+ Conent delivery button`

You'll have to provide a name to the content delivery config and export settings. The content delivery uses the same export
settings as described is the [export section](/platform/projects_and_organizations/export)

When the `Publish automatically` option is enabled, your localization files will be published automatically after every
change in your localization data. If you deselect the checkbox, you will have to publish your localization files
manually.

<ScreenshotWrapper src="/img/docs/platform/content-delivery/add-content-delivery.png" alt="Add Content Delivery" />

3. Use the Content Delivery link

Copy the link to your Content Delivery.

<ScreenshotWrapper src="/img/docs/platform/content-delivery/content-delivery-link.png" alt="Content Delivery link" />

The easiest way to connect Content Delivery with Tolgee SDK is through `BackendFetch` plugin.

```tsx
const tolgee = Tolgee()
...
.use(BackendFetch({ prefix: 'https://cdndev.tolg.ee/i18n/b53fb7fb98a57fd1f2ffc85ef5ee7b03' }))
...
```


This way, your localization files are stored outside your application, so you can update them independently from your release cycle.

:::info
Content delivery is made to be rapidly available all around the world, so we prioritize caching and using CDN over fast deployment. This means it can take up to 15 minutes (usually faster) for your changes to be published.
:::

> Read more about [providing Tolgee SDK with static data](/js-sdk/providing-static-data).
## Manual publishing

If you opted out of automatic publishing, you can do so manually in the list of content deliveries by `Publish` button.

<ScreenshotWrapper src="/img/docs/platform/content-delivery/manual-publish.png" alt="Manual publish" />


## Storage file structure

Your localization files are simply named by the language tags in the root folder of your storage link with the file extension (depending on your settings):

```
├── <your Content Delivery link>
│ ├── cs.json
│ └── en.json
```

If you use namespaces, it should look like this:

```
├── <your Content Delivery link>
│ └── common
│ ├── en.json
│ └── de.json
```

## Using custom storage
:::info Feature availability

Custom delivery storages are available in the Business and Enterprise plans. [Upgrade your plan](/pricing) to use this feature.

If you use the self-hosted version, you need to [set up the license](/platform/self_hosting/licensing) to use this feature.
:::

You can also connect the content delivery to your custom storage.

1. Open Content Storage settings

<ScreenshotWrapper src="/img/docs/platform/content-delivery/content-storage.png" alt="Content Storage" />

2. Add new storage

Tolgee supports S3 buckets and Azure blob storage. Fill in the settings that you obtain from your provider.

You can also test if your configuration is valid with the `Test` button.

<ScreenshotWrapper src="/img/docs/platform/content-delivery/add-content-storage.png" alt="Add Content Storage" />

3. Select the storage in the Content Delivery

After you create custom storage, the `Storage` field will appear in Content Delivery settings, so you can select your storage over the default one.

<ScreenshotWrapper src="/img/docs/platform/content-delivery/content-storage-select.png" alt="Content Storage select" />
2 changes: 1 addition & 1 deletion platform/projects_and_organizations/members.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You can choose the permissions that you want to give to the member. The permissi

### Granular permissions

:::info Paid feature
:::info Feature availability

Granular permissions are available in the Business and Enterprise plans. [Upgrade your plan](/pricing) to use this feature.

Expand Down
Loading

0 comments on commit 005c5f0

Please sign in to comment.