Closed myrdd closed 6 years ago
Regarding the current localization of the settings pages (XUL / HTML), see this piece of code: https://github.com/RequestPolicyContinued/requestpolicy/blob/5697d0e2d7d8aa56c86fc21bda5cc306e96bc5af/src/content/lib/utils/xul.js#L136-L160
Strings like "&foobar;"
are replaced by the string returned by StringUtils.$str("foobar")
.
I can take care of it because I will need it very soon for issue #871
I've created subtask issue #876: convert *.properties
to message.json
files
@jrrdev do you think you could take it?
The first three tasks are done :)
@jrrdev do you have some time to implement browser.i18n.getMessage()
, and to change the add-on's code to use that API function?
Please note that we can take browser.i18n.getMessage()
fake API code from Mozilla, see the issue's comment / the first comment.
(If it helps, you can also use this function: https://github.com/myrdd/requestpolicy/blob/17ff5d586b9974fe2c14999ace2e47169bd5edde/gulpfile.js#L225-L235)
Hi, I started to look at Mozilla's code but I didn't have much time last week to look deeper. Fortunately, I have a lot of free time this week :-) I hope to finish the remaining task by the end of the week
Great! :)
@myrdd I have some trouble to implement ExtensionData.readDirectory because I need to fetch the directory contents from chrome://rpcontinued/content/_locales
(thus it can't create a nsIFileURL because of scheme chrome://
).
I found a workaround using xhr and parsing the http response which looks like (I made a test on /content/bootstrap):
300: jar:file:///tmp/tmpC5HhWt.mozrunner/extensions/rpcontinued@non-amo.requestpolicy.org.xpi!/content/bootstrap/
200: filename content-length last-modified file-type
201: bootstrap.jsm 8674 Sun,%2017%20Dec%202017%2020:28:40%20GMT FILE
201: data/ 0 Sat,%2002%20Dec%202017%2019:01:14%20GMT DIRECTORY
201: environments/ 0 Sat,%2002%20Dec%202017%2019:01:14%20GMT DIRECTORY
201: modules/ 0 Sat,%2002%20Dec%202017%2019:01:14%20GMT DIRECTORY
But it seems a little hackish... Do you have some ideas on a better way to proceed with ?
@jrrdev IMHO you could simply hard-code the list of locales, just like it is done for install.rdf
. I've added commit https://github.com/myrdd/requestpolicy/commit/98458930858402297f09eba38966ada88311928f onto https://github.com/myrdd/requestpolicy/tree/feature/we-i18n. Now you can simply use bootstrap/data/locales
. :)
It is indeed much easier to deal with the hard-coded list :smile: Thank you !
I think this issue can be closed, no?
true, thanks
The WE i18n system is described here:
The main function we need is
browser.i18n.getMessage()
[MDN docs]:It will replace
StringUtils.$str()
.BTW, we do not need Locale-dependent CSS
Since we are going to maintain a XPCOM version of RPC (e.g. for palemoon) we need a
browser.i18n.getMessage()
fake API. We can take the code from Mozilla (licensed as MPL 2.0, so the copy-pasted code needs to be in a separate file with MPL2.0 header).I've tracked down the
browser.i18n.getMessage()
system:browser.i18n.getMessage()
ExtensionData.localizeMessage()
ExtensionData.localeData
LocaleData.localizeMessage()
Tasks
*.properties
tomessage.json
filesinstall.rdf
to the WE i18n json filesinstall.rdf
, replace all<em:localized>
lines by one single line containing<!-- @echo INSTALL_RDF_I18N -->
gulpfile.js
to create theINSTALL_RDF_I18N
string forinstall.rdf
by parsing the i18n json files.INSTALL_RDF_I18N
creation script in thepreprocessContext
gulp taskbrowser.i18n.getMessage()
functionStringUtils.$str()
bybrowser.i18n.getMessage()
*.properties
files