[Webextension] Sidebar + Internationalization

Talk about add-ons and extension development.
Post Reply
poltergeist0815
Posts: 2
Joined: December 3rd, 2017, 3:25 am

[Webextension] Sidebar + Internationalization

Post by poltergeist0815 »

Hello,

since I couldn't find anything in the porting guide or in this link https://developer.mozilla.org/en-US/Add ... nalization .. I also looked through the bugzilla and the forums and was quite astonished that I seem to either have quite a unique problem or that I am majorly dumb in general :P

The thing is, my own add-on was deactivated due to the recent change and I want to bring it back to life. Thus, I started out, porting each piece one by one (logic comes last). I also have a sidebar specially to configure the add on.

Now, in the old extension API you could use

Code: Select all

                        <label for="setting_criteria-txt" data-l10n-id="settings_criteria_label_id"></label>
for getting the localized string in your sidebar HTML. Obviously, it won't work anymore.
I tried with __MSG_myLabel__ without success. I thought of using "body onLoad="javascript: localize()" which then grants me a CSP violation (according to the debugger)... a simple "alert" won't trigger either. So, I guess that's out of option (though, I would have considered this a workaround if at all)

Which is now the way to get the HTML localized? Or is there even a simpler way to configure your add-on? At least back when I initially made it this was the easiest one (or rather, the one which was documented the best (with the "storage" attribute)).

Any hints to resolve this problem are appreciated!

Thank you in advance! :)
poltergeist0815
Posts: 2
Joined: December 3rd, 2017, 3:25 am

Re: [Webextension] Sidebar + Internationalization

Post by poltergeist0815 »

Well, I finally found something... :!:

https://developer.mozilla.org/en-US/Add ... Add-on_SDK tells us that WebExtensions dropped HTML internationalization. I didn't see that paragraph to be honest. However, it's supported in the add-on scripts.

Thus, with document.addEventListener("DOMContentLoaded", bootstrap ); it should be possible to have a javascript workaround catching all affected elements and execute the i18n functions in JS; replacing their textual content.

It's a shame to have this implemented so complicated. Really, I don't see the point in going "retro" and duplicate your HTML pages just with another language in them as the only way to get this multilanguage is to alter your manifest with the predefined constants to load a different html page (from a different directory). That is a maintenance hell which is bound to fail on the long term. ](*,)

Oh yea, I also dropped the sidebar in the process for "options_ui".

Any moderator may close the topic, as there is seemingly no interest in any kind of discussion regarding that (horrible) change after all... :roll:
Post Reply