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
14 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.

3 Likes

@Lhc_fl any plans for this? Your plugin seems to be what I need to fix some of the terminology for my community in French, but I’m worried about breaking stuff as described in the post above by tomtjes.

Why did the replacement fail?

(This is the Globally replace translations plugin)

Perhaps you need to use => instead, as in the = and > signs? The arrow in your screenshot doesn’t look correct.

The use of symbols is indeed correct; they are separate = and > symbols. It only appears that they are connected due to a display issue.

1 Like

Understood, in any case, this should be moved to that plugin’s topic, as it is not official.

Okay, understood. Thanks for letting me know. (Why do I need to reach 20 characters to reply?)

If I understand the code correctly, the plugin uses JsLocaleHelper to replace the text used in the frontend (the content of client.*.yml). server.*.yml, which for example contains the descriptions of site settings, remains unchanged.

Is “azy videos just an example of what you want to use the plugin for? The plugin was designed to replace a specific term across a large number of texts. Since this text only appears once in the forum, you could just edit the text directly without using the plugin. There is a guide on how to do that: Customize text in Discourse

2 Likes

I want to modify these English texts, but I can’t find them.


1 Like

Those are the names of the settings. I explained why they are not translatable in 有没有比较好的中文插件 - #2 by Moin.
You cannot customize texts that aren’t translatable in the admin interface.

By the way, if I happened to overlook something regarding this plugin’s ability to also modify backend text, I’m still pretty sure that it only changes translatable text, not other text in the interface. It’s about replacing words in texts, not allowing the translation of untranslatable texts.

2 Likes