Can you override the locale via theme files?

AI-generated summary

The discussion revolves around overriding locale text in Discourse themes. sevadev-ramchandra asks if it’s possible to change placeholder text via locale files within theme files, noting that attempts using config/locales/client.en.yml and locales/en.yml were unsuccessful. Lhc_fl confirms that locale overrides can be achieved using JavaScript, such as I18n.translations[I18n.currentLocale()].js.composer.reply = "ylper";, but Lhc_fl is unsure if this can be done via YAML locale files. Canapin questions the need for this approach, pointing out that modifying Discourse core files risks being overwritten during updates. awesomerobot suggests combining both methods, allowing translation keys to be used dynamically via I18n.t(themePrefix("my_translation_key")).

I want to change some placeholder text, and I want it do via locale files, so there any way to do?

I have tried using by creating config/locales/client.en.yml, previously there was not those files present in themes, I also tried using locales/en.yml, but none of these works.

I think I can do this via admin settings → text and change value from there, but I want to achieve that from discourse theme files.

So is there any working method to achieve this?

Yes, you can.

An example:

I18n.translations[I18n.currentLocale()].js.composer.reply = "ylper";

Can we achieve that from locale yml files ?

I don’t know, I haven’t found any example of this yet. (maybe there are too few theme components I’ve looked at)

Hi :slight_smile:

Why?

If you change Discourse’s files, they will be overwritten each time you update it.

You can combine these two approaches, so something like:

I18n.translations[I18n.currentLocale()].js.composer.reply = I18n.t(themePrefix("my_translation_key"));