# Instrumenting your code

## locizify

> Zero effort - drop one line of code.

Using our locizify script is the simplest way to get your website or webapplication translated. We highly recommend using it on your static site generators like wordpress, shopify, ...

![](https://103615269-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9pm8yQi-Jkj6yuulDv%2F-L9pmDrQ7WeOrUCL2dZW%2F-L9pmN4W2PzO4kLp80xo%2Flocizify-frameworks.png?generation=1523468307838050\&alt=media)

Drop one line of code:

```javascript
<script
    id="locizify" projectid="[PROJECT_ID]"
    apikey="[API_KEY]" referencelng="[LNG]"
    fallbacklng="[LNG]" saveMissing="true"
    src="https://unpkg.com/locizify@^6.0.11"
    autopilot="true"
></script>
```

*You can find your projectId and API Key in your projects settings. (You should not expose your write API key into production - only use it during development)*

Reload your page and see the phrases ready to translate in your locize project.

Find more details and configuration options on the [github page](https://github.com/locize/locizify).

{% embed url="<https://youtu.be/f0ukRI0LMfo?t=180>" %}
<https://youtu.be/f0ukRI0LMfo?t=180>
{% endembed %}

## i18next

> Best translation management for [i18next](https://locize.com/i18next.html).

You can use locize in combination with i18next. I18next is a well known internationalization framework and offers a wide range of framework integrations and plugins for almost every need.

![](https://103615269-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9pm8yQi-Jkj6yuulDv%2Fuploads%2FupLULMB8Nln11Lxc3e04%2Fi18next_eco.jpg?alt=media\&token=447f1844-9c2b-4e26-a073-f7f5d37e09cf)

[Learn more about i18next](http://i18next.com)

{% embed url="<https://youtu.be/SA_9i4TtxLQ>" %}

{% hint style="success" %}
[Here](https://locize.com/blog/react-i18next/) you'll find a simple tutorial on how to best use [react-i18next](https://react.i18next.com/).\
Some basics of i18next and some cool possibilities on how to optimize your localization workflow.[\
](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb)[<img src="https://103615269-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9pm8yQi-Jkj6yuulDv%2F-Mash2FLLqe6lywdMBJR%2F-MashHQJX9RaSVLxXK5z%2Ftitle%20width.jpg?alt=media&#x26;token=93439569-81c4-441a-a2fc-ca49f00bd38e" alt="" data-size="original">](https://locize.com/blog/react-i18next/)
{% endhint %}

To connect i18next with the locize service integrate the [i18next-locize-backend](https://github.com/locize/i18next-locize-backend):

```javascript
import i18next from 'i18next';
import Backend from 'i18next-locize-backend';

i18next
  .use(Backend)
  .init({
    // ...other options
    backend: {
      projectId: '[PROJECT_ID]',
      apiKey: '[API_KEY]',
      referenceLng: '[LNG]'
    }
  });
```

*(You should not expose your write API key into production - only use it during development)*

[Here you can find a step by step react tutorial.](https://github.com/locize/react-tutorial)

{% embed url="<https://www.youtube.com/watch?v=RodGMOLIJog>" %}
[code integration](https://www.youtube.com/watch?v=RodGMOLIJog) part of [showcase/demo](https://www.youtube.com/watch?v=TFV_vhJs5DY)
{% endembed %}

### Other i18next tutorials:

{% hint style="success" %}
[Here](https://locize.com/blog/unleash-the-full-power-of-angular-i18next/) you'll find a simple Angular tutorial on how to best use [angular-i18next](https://locize.com/blog/angular-i18next/).[\
](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb)[<img src="https://103615269-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9pm8yQi-Jkj6yuulDv%2F-Mc8EsLhuioswi2S8nYd%2F-Mc8F4e0JIMU4rEo50B-%2Ftitle.jpg?alt=media&#x26;token=0f049be5-af13-461a-aee2-06f3220e715f" alt="" data-size="original">](https://locize.com/blog/unleash-the-full-power-of-angular-i18next/)
{% endhint %}

{% hint style="success" %}
Are you still using i18next in [jQuery](https://github.com/i18next/jquery-i18next)? Check out [this tutorial blog post](https://locize.com/blog/jquery-i18next/).

[![](https://103615269-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9pm8yQi-Jkj6yuulDv%2Fuploads%2F0t3jLGyHeL0ncnxrExAW%2Fjquery-localization.jpg?alt=media\&token=60209b4b-53a8-4268-af6a-9380caac148a)](https://locize.com/blog/how-to-jquery-i18next/)
{% endhint %}

{% hint style="success" %}
**Are you using** [**Next.js**](https://nextjs.org/)**?**\
[Here](https://github.com/locize/next-i18next-locize) you can find an example with different approaches and a [blog post](https://locize.com/blog/next-i18next/) explaining this.

[![](https://103615269-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9pm8yQi-Jkj6yuulDv%2Fuploads%2FXF0ynTNGbvAAMQnyzXZ8%2Fnext-i18next.jpg?alt=media\&token=db8df980-2999-4492-8b30-2422a0589b9d)](https://locize.com/blog/next-i18next/)\
\
**Using Next.js 13/14 with the new app directory?**\
Then [this article](https://locize.com/blog/next-app-dir-i18n/) is what you are looking for.

[![](https://103615269-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9pm8yQi-Jkj6yuulDv%2Fuploads%2Fag36ZOVEq8VTFGpLXWFj%2Fnext-13-app-dir-i18n.jpg?alt=media\&token=b98d660a-c114-43ea-ba21-b74181f434de)](https://locize.com/blog/next-app-dir-i18n/)
{% endhint %}

{% hint style="success" %}
**Are you using Gatsby?**\
[Here](https://github.com/locize/locize-gatsby-example) you can find an example and an appropriate [blog post](https://locize.com/blog/gatsby-i18n/).

[![](https://103615269-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9pm8yQi-Jkj6yuulDv%2Fuploads%2FkQwR5Z4i4GOKsEBLVMiX%2Fgatsby-i18next.jpg?alt=media\&token=c7c6c8ac-09e9-4a57-91d0-ab55b5778dc7)](https://locize.com/blog/gatsby-i18n/)
{% endhint %}

{% hint style="success" %}
**Are you using** [**Remix**](https://remix.run/)**?**\
[Here](https://github.com/locize/locize-remix-i18next-example) you can find a simple example and a [step by step tutorial](https://locize.com/blog/remix-i18next/).

[![](https://103615269-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9pm8yQi-Jkj6yuulDv%2Fuploads%2FZOOEXFBVtMszdhTXaTUo%2Fremix-localization.jpg?alt=media\&token=f50c6677-7ced-4174-b53f-54e6a340c922)](https://locize.com/blog/remix-i18next/)
{% endhint %}

{% hint style="success" %}
**Are you using** [**Vue.js**](https://vuejs.org/)**?**\
[Here](https://github.com/locize/locize-i18next-vue-example) you can find a simple example and a [step by step tutorial](https://locize.com/blog/i18next-vue/).

[![](https://103615269-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9pm8yQi-Jkj6yuulDv%2Fuploads%2FhMFf7HK043TkxYomIJie%2Fi18next-vue.jpg?alt=media\&token=de70fec1-74f7-4f08-ae5c-74c56697e3d0)](https://locize.com/blog/i18next-vue/)
{% endhint %}

## other options

### client side: polyglot, formatjs, react-intl, vue-i18n, js-lingui, messageformat, ...

{% hint style="info" %}
For server side rendering (SSR) or serverless usage, we do **not** suggest to use our locizer script. Because of this we suggest to download the translations in your CI/CD pipeline (via [cli](https://github.com/locize/locize-cli#download-current-published-files) or via [api](https://docs.locize.com/integration/api#list-all-namespace-resources)) and package them with your application. Like described [here](https://github.com/locize/i18next-locize-backend#important-advice-for-serverless-environments---aws-lambda-google-cloud-functions-azure-functions-etc).
{% endhint %}

On client side, you can use our [locizer](https://github.com/locize/locizer) script to load translations from locize and add them to your i18n framework in the browser:

Sample for polyglot:

```javascript
// <script src="https://unpkg.com/locizer/locizer.min.js"></script>
locizer
  .init({
    fallbackLng: 'en',
    referenceLng: 'en',
    projectId: '[your project id]'
  })
  .load('translation', function(err, translations, lng) {
    const polyglot = new Polyglot({ phrases: translations, locale: lng });
    console.log(polyglot.t('some key'));
  });
```

Sample for vue-i18n (Vue v3):

```javascript
import { createI18n } from 'vue-i18n'
import locizer from 'locizer'

locizer.init({
  projectId: 'project-id'
});

export const i18n = createI18n({
  locale: locizer.lng, // set locale
  fallbackLocale: 'en' // set fallback locale
  // If you need to specify other options, you can set other options
  // ...
});

// called from within setup hook in App.vue
export const loadMessagesPromise = new Promise((resolve, reject) => {
  locizer.loadAll('messages', (err, messages) => {
    if (err) return reject(err);
    Object.keys(messages).forEach((l) => {
      i18n.global.setLocaleMessage(l, messages[l])
    });
    resolve(messages);
  });
})
```

*The full example can be found* [*here*](https://github.com/locize/locizer/tree/master/example/vue)*.*

{% hint style="success" %}
[Here](https://locize.com/blog/give-vue-i18n-more-superpowers/) you'll find a simple tutorial on how to best use [vue-i18n](https://kazupon.github.io/vue-i18n/).\
Some basics of vue-i18n and some cool possibilities on how to optimize your localization workflow.[\
](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb)[<img src="https://103615269-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9pm8yQi-Jkj6yuulDv%2F-MbeAnns1DYF1tOv9XWX%2F-MbeBOCYvK-qA0FdGdSb%2Ftitle.jpg?alt=media&#x26;token=403c12ad-4d68-444b-8c99-c9abe23900e9" alt="" data-size="original">](https://locize.com/blog/give-vue-i18n-more-superpowers/)&#x20;
{% endhint %}

For more details checkout [locizer docs](https://github.com/locize/locizer).

Our samples:

* [react-intl](https://github.com/locize/locize-react-intl-example)
* [vue-i18n](https://github.com/locize/locizer#vue-i18n-vue-v3)
* [svelte-i18n](https://locize.com/blog/svelte-i18n/)
* [formatjs](https://github.com/locize/locize-formatjs-example)
* [polyglot](https://github.com/locize/locize-polyglot-example)
* [js-lingui](https://github.com/locize/locize-js-lingui-example)
* [ngx-translate](https://github.com/locize/ngx-translate-example)
* [transloco](https://github.com/locize/transloco-example)

### 3rd party modules

* [react-intl-namespaces](https://github.com/maciejw/react-intl-namespaces) Integrations of react-intl internationalization library with locize.com online translation service. Comes with support for namespaces, incontext editor, ...

### serverside

{% hint style="success" %}
Did you know internationalization is also important on your app's backend? In [this tutorial blog post](https://locize.com/blog/how-does-server-side-internationalization-look-like/) you can check out how this works.[\
](https://dev.to/adrai/how-to-properly-internationalize-a-react-application-using-i18next-3hdb)[<img src="https://103615269-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9pm8yQi-Jkj6yuulDv%2F-MdMqtpCqhjyVrOwYZAT%2F-MdMr1-Gs4tcF0TcyRDb%2Fserver_side_backend.jpg?alt=media&#x26;token=667ee6f8-6c17-460a-a90a-3a5250ee7717" alt="" data-size="original"> ](https://locize.com/blog/how-does-server-side-internationalization-look-like/)
{% endhint %}

For JavaScript environments please watch out for the [i18next integration options](https://www.i18next.com/overview/supported-frameworks) and [plugins](https://www.i18next.com/overview/plugins-and-utils#backends).

On other environments you could use:

* [Our API](https://docs-old.locize.com/integration/api)
* [Our locize-cli](https://github.com/locize/locize-cli)

### other formats xliff, gettext, ...

You can use following modules to convert between formats:

* [xliff](https://github.com/locize/xliff)
* [android-string-resource](https://github.com/locize/android-string-resource)
* [gettext (.mo/.po)](https://github.com/i18next/i18next-gettext-converter)

Simplest is to use those in combination with our [cli](https://github.com/locize/locize-cli) to build an automated production pipeline powered by grunt, gulp, npm script, ...
