Globally replace translations

:information_source: Summary This plugin allows you to globally replace certain words in the translation
:hammer_and_wrench: Repository Link https://github.com/Lhcfl/replace-translations-global
:open_book: Install Guide How to install plugins in Discourse

Features

Literally, replace all occurrences of a word with another word

For example, replace “Topic” with “Nya”:

Configuration

I believe its settings are self-explanatory :slightly_smiling_face:

Note that translations are cached and changing them takes time. You can do this to force update:

sudo ./launcher enter app
rm -rf tmp
12 Likes

Can this replace the official custom text?

This is the problem I’m currently encountering: I cannot modify those key-values in bulk!

Or @Lhc_fl do you have a better method?

This plugin is used for batch replacement of translations. However, due to caching, you may need to rebuild after replacement for it to take effect.

Is there no batch modification method provided by Discourse itself? For example, exporting a YAML file and replacing it via VS Code?

There is no such method, you can only change them one by one

Then your tools are indeed very good!

Does every change require a manual rebuild with ./launcher rebuild app?
sudo ./launcher enter app
rm -rf tmp
I haven’t found its use.

Try ./launcher restart app first (after deleting tmp)?

I deleted tmp in the development environment, so it might have been automatically applied here.

If that doesn’t work, try rebuilding. The language files might be pre-compiled, and the plugin’s mechanism interferes with the function that reads the language yml, running only on the first load.

1 Like

Just a reminder that including an English translation makes it much easier for others to follow along, :pray:

4 Likes

I just tried it, and it will oops, it’s better to rebuild it to be stable.

If using this to substitute another term for category be aware that this plugin also replaces the word in templates such as {category}, leading to errors in the UI. To avoid this, I’m using the regex
en:(?<!\{)category(?!\})=>chapter
in the plugin settings, but perhaps the plugin should be adjusted to only target user-facing content.

2 Likes