Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
160 views
in Q2A Core by
What is the best way to override the text of emails, defined in qa-lang-emails.php? I'd like to do it in a way that isn't lost whenever a new version is installed, if possible.

Or, is there a better solution to the problem of users replying to the emails that tell them their question has been answered/commented, in the expectation that their reply will appear on the site?

The only simple answer seems to be an extra sentence at the start of the relevant emails.
Q2A version: 1.8.0
by
If your site is in English,  I guess, you can always download a British English or GB English or Canadian English or Australian language pack. Those language packs are unaffected by the core updates.
by
Nice idea. Does a British English language pack exist? And what happens to it when a new version has new language elements?
by
I think there is a default en-GB folder in /qa-lang/ . I think you can duplicate it and rename as en-Canada. Not sure if you need some minor changes such as metadata or similar. But I'm sure that the core updates won't affect en-Canada folder. So you just change your site language to Canadian language. I will check later if I have time next morning.
by
I'm not 100% sure that the en-GB will remain intact after core update because it's still a default folder and developers can do whatever.

But you can create a Canada package easily. First, duplicate the en-GB folder and rename it as en-Canada. Second, change the ├Čnformation in the metadata.json file. Third, copy all files in /qa-include/lang folder into your /qa-lang/en-Canada.

Now you can edit your email preferences.

If new Q2A update has new language elements, just add what is missing.

If you don't add, the language will be English, not Canadian.

(Of course Canadian language here is just psuedo)

1 Answer

+1 vote
by

Write a custom plugin where you override the function qa_lang(). Something like

function qa_lang($identifier) {
    if (substr($identifier, 0, 7) === 'emails/') {
        # your code here
        return ...
    } else {
        return qa_lang_base($identifier);
    }
}

...