I need to create an extension that would change my browser locale on a mouse click.
I'm developing a bilingual web app, and I'm setting the i18n messages according to the browser locale. But this requires me to get to the wrench, then under the hood, then languages, then the drag&drop thing to switch the locale. Searching the chrome extensions didn't bring any results. I'm now trying to make a chrome extension which would make this a click or two closer, but I'm having troubles doing that.
I can get to the list of accepted languages with chrome.i18n.getAcceptLanguages(callback), but I don't know how to set the locale (or reorder or whatever).
Can somebody tell me which function ot use or even if there already is such an extension?
Well, does this help?
http://www.chromium.org/developers/design-documents/extensions/proposed-changes/apis-under-development/preference-api
Use cases
It allows extensions to read and write the browser preferences. Given accept languages as an example, page translation extension and dictionary extension will need to get the accept languages from the browser and use them as the targeted languages for page or word translation.
It lists:
chrome.preferences.
void getAcceptLanguages(void callback(String acceptLanguages))
void setAcceptLanguages(Value newAcceptLanguages)
void appendAcceptLanguage(Value acceptLanguage)
Related
I want to make a new WebExtensions add-on to change the color of my tab but I didn't find anything applicable. tabs.insertCss() can be used only to change CSS inside tab content, but can not style the tab bar
Short answer: You can't do so right now.
Longer: An API is being worked on which will allow some limited changes to the browser UI, which might include what you desire. The API, browser.theme.update(), currently exists in Nightly (Firefox 55). It used to be behind a preference, but is now enabled by default. This API does not permit you to insert arbitrary CSS. You will only be able to change the things specifically included in the API. Inserting arbitrary CSS is something that explicitly won't be permitted.
See:
Blog post announcement: Improving Themes in Firefox
Beginning of a thread on dev-addons
Continuing that dev-addons thread a month later
Main tracking bug for all feature development related the new theming API
I have two different language i.e English and German in my web app and user can change the language in application through a select box. Initially i am getting preferred language from the back-end and i am setting locale of the core as follows.
sap.ui.getCore().getConfiguration().setLanguage("//according to whatever is coming from back-end")
Now lets say initial language is English, if user open a control i.e sap.m.datepicker, calendar is being displayed in English. If user changes the language to German from the application i am again changing the language in the core as shown below:
sap.ui.getCore().getConfiguration().setLanguage("de-DE")
Now if user opens that same datepicker, it is being displayed in English instead of German and if user opens some another control or datepicker it is being rendered in German.
Page is not getting refreshed while changing the language in app.
Please suggest me a solution to dynamically change the locale of the controls.
Maybe my answer here helps a little.
The problem is that in many cases, maybe even in most cases, the standard UI5 controls detect the language only once when they get loaded. Very often, the control developers did not implement a "dynamic change" of the language. If you check the link I mentioned above you will see that there are ways to react on language changes, but very often this is not implemented for whatever reason.
However, I'm afraid to tell you that in your case the standard control might not support dynamic language changes out of the box (but I did not check the code). Also, it seems that the UI5 guys at SAP do not consider this as a bug (see this github issue). Such a pity...
I would suggest you use sap.ui.core.Core.attachLocalizationChanged(fnFunction, oListener) and add this to the onInit function of your controller.
From this, in your fnFunction rebuild the controls where you require the locale changes to be dynamic.
example:
onInit: function(oEvent) {
sap.ui.getCore().attachLocalizationChanged(this._handleLocalizationChanged, this);
},
_handleLocalizationChanged: function() {
// ... Some logic to re-build / set locale for the dynamic controls.
}
This is my interpretation of what should be done based on the information in the api
Firefox has come to believe that my default spell check language should be Spanish. My global preferences have English selected:
Preferences->Content->Languages->English [en]
and on a page-by-page basis I'm able to reset the spell checker language via:
Right click->Languages->English (United States)
However, for newly opened pages or new sessions the default spell check language returns to Spanish. I found a workaround here:
https://support.mozilla.org/en-US/questions/975459#answer-494574
Which suggested that installing a new dictionary would change the default. However, this issue has bugged me for so long that I would like to know if there is a more "correct" way to change the default spell check language.
If you only use system wide spell checking dictionaries (for example, the hunspell package provided by your Linux distribution) Firefox seems not be able to remember the default configuration (is this a bug?). You can fix this issue by having at least one dictionary installed as a Firefox plugin.
Afaik, there is no UI for this. Instead you have to use about:config and set dictionary.spellchecker.
Also, Content > Languages has no bearing on spell checking. This effects what content you're given on multilingual websites.
More specifically, the idea is to allow the user to open Firefox, highlight a word on a web page, right click on it, and have an additional option that, when selected, calls c++ code that does something with the input string (must call C++ code, unfortunately), and displays a dialog box showing the result.
I'm still not sure if in order to implement this functionality I need to create a Firefox plugin or an extension. Can someone point me in the right direction?
Also, if someone can show me sample code in order to get me started that would be appreciated. (XPCOM, which I'm not even sure is what I should be using, seems a bit complicated for this seemingly simple project.)
You need a regular Firefox extension. It can add an item to the context menu, NPAPI plugins cannot do this. When it is clicked it can get the selected text and send it to your binary library. The best way to call functions in this library is js-ctypes, XPCOM is not required.
I am using a Web view in my application, instead of open a Safari browser instance, so I noticed that Safari extensions doesn't work. Is there a possibility to enable this feature when using a custom web view in a Cocoa Application?
The reason by which I need to use Safari extensions is to inject javascript to whatever web page is loaded at one moment, so if is there another approach to do it without using extensions, welcome any suggestions or samples.
There's no way to use Safari extensions in a web view.
If your script isn't too big, how about formatting it as a "javascript:" bookmarklet and setting the web view's location to it?
[Edit: Stuff below added in response to questioner's request for "a bit more about that technique".]
Say you want to change the background color of the page to yellow and all the text to red. The javascript to do that would be something like:
document.body.style.backgroundColor = "yellow";
document.body.style.color = "red !important";
To turn the script into a bookmarklet, you just:
Wrap it in an anonymous function,
remove all line breaks,
(optionally) remove any unnecessary spaces,
url-encode it,
and prefix the whole thing with "javascript:".
So, the example would become:
javascript:(function(){document.body.style.backgroundColor%3D%22yellow%22%3B%0Adocument.body.style.color%3D%22red%20!important%22%3B%0A}());
Then you can set the webview's window.location to that string to "run" the bookmarklet.
Here is a page with an automatic script to bookmarklet converter that seems to work.