Create a Custom Translation File for Your Widgets

- Posted in Tutorials by

By default, API-SPORTS widgets are available in four languages: English, French, Spanish and Italian.

But you might want to adjust some wording for your audience, for example replacing Finished by Completed or translating terms into another language.

The good news is that widgets support custom translation files.

1. Create your JSON file

A custom translation file is a simple JSON document. You only need to declare the keys you want to override.

Example:

{
  "all": "All Games",
  "finished": "Completed",
  "favorites": "My Teams"
}

In this example, only three terms are changed. All other terms will still be displayed in the base language defined with data-lang.

If you want to go further, you can download the full translation file for each language from our documentation here and use it as a base to replace every label.

2. Host your file

Upload your JSON file to your own server or CDN so it can be accessed via HTTPS.

Example URL:

<https://yourdomain.com/lang/en.json>

3. Use it in your widget configuration

Now you can load your custom translations by adding the data-custom-lang attribute to your configuration widget.

<api-sports-widget
  data-type="config"
  data-key="Your-Api-Key"
  data-sport="football"
  data-lang="en"
  data-custom-lang="https://yourdomain.com/lang/en.json"
></api-sports-widget>

Here, the base language is English (data-lang="en") and your custom file will override specific terms.

4. Replace the entire wording if needed

If you prefer, you can take the full translation file we provide for each language and modify it to suit your needs. This way, you control every single label used by the widgets.

5. What happens if a key is missing?

Don’t worry: if your custom file does not include some keys, the widget will automatically fall back to the base language defined in data-lang.

That’s it. You now have everything you need to customize the wording of your widgets and adapt them to your audience.

For more details, check out the full documentation