# Sage 10.x Localization strings with WPML

**URL:** https://discourse.roots.io/t/sage-10-x-localization-strings-with-wpml/24228
**Category:** sage
**Tags:** sage10
**Created:** 2022-11-14T10:12:08Z
**Posts:** 6

## Post 1 by @Frykky — 2022-11-14T10:12:08Z

Hi,  
in my file /resources/views/partials/related-events.blade.php i wrote this code

```
<h4 class="my-5">{{_e('Potrebbero interessarti anche', 'my-theme')}}</h4>
```

Follow this guide [Sage 10.x: Localization | Roots Documentation](https://docs.roots.io/sage/10.x/localization/#generating-language-files) i installed gettext in WSL, i run yarn pot, i opened sage.pot with POedit, translate “Potrebbero interessarti anche” in “Related events”

add this code in app/setup.php

```
add_action('after_setup_theme', function () {
    load_theme_textdomain('my-theme', get_template_directory() . '/lang');
});
```

Uploaded all files and folder but i still view only the source string non the translated version.

I use WPML with string translation.  
Where am i wrong?

---

## Post 2 by @strarsis — 2022-11-14T15:23:52Z

The POT file is only a template (`T` stands for template), you have to save a `PO` file and then save/compile that to a `MO` file, which is actually used by WordPress/PHP.  
Also ensure you have the correct locale set up to be used by the site, and that the `MO` (and therefore also the source `PO` file) have the proper locale in the filename.  
For example, for German formal translation I would have two files in the `resources/lang/` directory, `de_DE_formal.po` and `de_DE_formal.mo`.

WPML should support native WordPress translation and only override string translations for those strings also added in the WMPL plugin: [Using PO/MO files instead of String Translation - WPML](https://wpml.org/forums/topic/using-po-mo-files-instead-of-string-translation/)

---

## Post 3 by @GamendeBrian — 2024-10-22T14:14:15Z

In case anyone else stumbles upon this.  
WPML doesn’t compile the blade syntax properly, so you’ll have to use default php code.  
In this case for example:

```
<h4 class="my-5"><?php echo _e('Potrebbero interessarti anche', 'my-theme') ?></h4>
```

Hope this helps.

---

## Post 4 by @strarsis — 2024-10-22T14:28:50Z

> [@GamendeBrian](#):
>
> WPML doesn’t compile the blade syntax properly

The `WP` `i18n` CLI command natively supports Blade-PHP templates by the way, and it can generate a POT file from Blade-PHP/PHP/JSON-files.

---

## Post 5 by @GamendeBrian — 2024-12-16T14:25:04Z

Yes, but the String Translation functionality for “Localization of themes and plugins” won’t recognize it when using blade syntax.

---

## Post 6 by @strarsis — 2024-12-16T14:30:57Z

I am not using WPML, but it appears as it can import PO-files (that can be generated `WP` `i18n` CLI from Blade-PHP files):

- [Importing PO files - WPML](https://wpml.org/forums/topic/importing-po-files-2/)
- [https://wpml.org/forums/topic/using-existing-po-files/](https://wpml.org/forums/topic/using-existing-po-files/)
- [https://wpml.org/forums/topic/is-there-a-way-to-use-automatic-translation-for-a-po-file/](https://wpml.org/forums/topic/is-there-a-way-to-use-automatic-translation-for-a-po-file/)
