# Discourse-multilingual-post

**URL:** https://meta.discourse.org/t/discourse-multilingual-post/139689
**Category:** Plugin
**Created:** [January 24, 2020, 11:53pm UTC](https://meta.discourse.org/t/discourse-multilingual-post/139689 "2020-01-24T23:53:28Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![syl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/syl/32/98883_2.png) [@syl](https://meta.discourse.org/u/syl)
#### Post date: [January 24, 2020, 11:53pm UTC](https://meta.discourse.org/t/discourse-multilingual-post/139689/1 "2020-01-24T23:53:29Z")

</div>

# discourse-multilingual-post

A Discourse plugin that allows multiple localized versions of post content.

**This plugin is a proof-of-concept** : without the possibility to localize topic titles, it is not very useful.

## How to use

In a post, use `[lang=xx]` blocks:

```plaintext
[lang=en]
Hello World!
[/lang]
[lang=fr]
Bonjour monde !
[/lang]
[lang=de]
Hallo Welt !
[/lang]

```

Result:

> Hallo Welt !

Country codes must be 2-letter long (regions are not supported).

## How it works

When rendering a post, the plugin seeks one `[lang=xx]` block to display. It will stop seeking once it has found:

1. the block set for the **language of the user** (as selected by Discourse)
2. the block set for the **default language of the Discourse instance**
3. the **first block**

## Repository

[https://github.com/sylque/discourse-multilingual-post](https://github.com/sylque/discourse-multilingual-post)

---

<div class="post-metadata">

### Author: ![syl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/syl/32/98883_2.png) [@syl](https://meta.discourse.org/u/syl)
#### Post date: [January 25, 2020, 12:00am UTC](https://meta.discourse.org/t/discourse-multilingual-post/139689/2 "2020-01-25T00:00:51Z")

</div>

Discourse team, any idea how I could localize topic titles?

What I would like to do is this:

- Define a language order, for example “en,fr,de”
- Allow users to write topic titles like this: `Hello World#Bonjour monde#Hallo Welt`
- When Discourse displays a topic title, modify it to only keep the right language

However, I found no client-side hook to modify the title. Any idea?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [January 25, 2020, 12:09am UTC](https://meta.discourse.org/t/discourse-multilingual-post/139689/3 "2020-01-25T00:09:35Z")

</div>

Did you consider handling titles in Rails? Default language is the existing one, while additional titles are custom topic fields. Then you change serializers to send the selected language title in the payload.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [January 25, 2020, 12:11am UTC](https://meta.discourse.org/t/discourse-multilingual-post/139689/4 "2020-01-25T00:11:42Z")

</div>

Great work!

> [@Falco](#):
>
> Did you consider handling titles in Rails? Default language is the existing one, while additional titles are custom topic fields. Then you change serializers to send the selected language title in the payload.

I would second this. I think server-side is the way to go for titles.

I’m actually in the process of building a multilingual plugin (almost finished) that allows for translations of:

1. Tags
2. Category names
3. Caegory descriptions

As well as an admin panel to administer languages and locales and a bunch of other things like user specific language content filters.

[https://github.com/paviliondev/discourse-multilingual](https://github.com/paviliondev/discourse-multilingual)

There could be scope to combine forces here.

---

<div class="post-metadata">

### Author: ![jadenfreude](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jadenfreude/32/183108_2.png) [@jadenfreude](https://meta.discourse.org/u/jadenfreude)
#### Post date: [September 10, 2020, 7:48pm UTC](https://meta.discourse.org/t/discourse-multilingual-post/139689/5 "2020-09-10T19:48:41Z")

</div>

Hello! I love this plugin and how simple it is and I feel that it’d be more useful if it supported decorating discourse pages (FAQ/Guidelines, TOS, Privacy Policy) since the headings get translated anyways. I’ve tried forking and expanding on it myself, but to tell you the truth I’m an absolute novice. Although I have a feeling that it needs to be rewritten around `decorateWidget()` instead of `decorateCooked()`.

---

<div class="post-metadata">

### Author: ![syl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/syl/32/98883_2.png) [@syl](https://meta.discourse.org/u/syl)
#### Post date: [September 10, 2020, 9:37pm UTC](https://meta.discourse.org/t/discourse-multilingual-post/139689/6 "2020-09-10T21:37:18Z")

</div>

Decorating a Discourse static page (FAQ/Guidelines, TOS, Privacy Policy) would be a nice feature. However, I’m not sure `decorateWidget` has a hook into static pages. Someone, any hint on this?
