I have the following en.js in my project to extend your i18n text but the strings are only appended to the WET dictionary after all is loaded which is a problem. How could I get it to load before all plugins? How do I use the mixin feature to inject an int?
$(document).on("wb-ready.wb",` function (event) {
if (document.getElementsByTagName("html")[0].getAttribute("lang") !== "en")
return;
wb.i18nDict["sectContainsError"] = "This section contains 1 error.";
wb.i18nDict["sectContainsErrors"] = { mixin: "This section contains [MIXIN] errors." };
});
A such global extend do not currently exist in the wet-boew core.
Usually, the i18n can be extended at the plugin level. But I will need to know what plugin you are trying to customize because some plugin might not support it yet.
What is your use case?
Are looking to do a global override because the current translation is wrong? If so, it is possible to make change to the i18n global string.
I created a new form validation plugin that goes a step further than yours. I have new strings I'd like to add to the existing WET i18n dictionary so I can use WET's dictionary natively and if needed re-use my new strings elsewhere. Just trying to re-use/extend what's already there.
I looked at the wet core code, and I think you can do it the first time the timerpoke is triggered on the form validation or another plugin.
May be something like:
$(".wb-frmvld").one("timerpoke.wb",` function (event) {
if (document.getElementsByTagName("html")[0].getAttribute("lang") !== "en")
return;
wb.i18nDict["sectContainsError"] = "This section contains 1 error.";
wb.i18nDict["sectContainsErrors"] = { mixin: "This section contains [MIXIN] errors." };
});
An alternative would be to let the wb core to trigger an event or to call a callback immediately after the dictionary is loaded https://github.com/wet-boew/wet-boew/blob/master/src/core/wb.js#L608
Similarly done in https://github.com/wet-boew/wet-boew/issues/5624.
Hi @RobJohnston, did you manage to accomplish what you were looking for? If so, feel free to close this issues. Thanks!
I bounce that question to @vallieresc and leave it to him to close.
@GormFrank I didn't get around to it. I'm pulled elsewhere at the moment but the solution @duboisp proposes looks to make sense.