Can not change language with cobalt preload mode - cobalt

With cobalt preload mode, it can not change the language as the language setting is set at the initialization of cobalt, so is there a way to to support it?
//src/cobalt/browser/application.cc
// Get the system language and initialize our localized strings.
std::string language = base::GetSystemLanguage();
base::LocalizedStrings::GetInstance()->Initialize(language);

The language is sent with the initial URL request in the HTTP headers, so if the language changes, you will want to reload the application URL anyway. Otherwise, the UI will not be in the correct language.
So, if the language changes, I would suggest shutting down Cobalt and starting it again, so hopefully it will be loaded in the new language by the time the user switches to it.
Alternatively, when launching Cobalt, you could check to see if the language is different and restart it at that point, but then the user will definitely have to wait for the full application startup.

Related

Can UFT/QTP switch system locale?

I have a test case which requires me to first change the system's locale and then start the test. I want to automate the process of changing the system locale with qtp/uft, is that possible?
Can UFT/QTP automate the change of the system locale on a window machine?
Yes you can. At the start (or other appropriate point) of your test use SetLocale(lcid) like this:
SetLocale("en-gb") ' sets locale to UK
SetLocale("en-us") ' sets locale to US
SetLocale("de") ' sets locale to Germany
This link will show you the various lcids available for use
The WINAPI SetThreadLocale might be a way of doing that, with the restriction that only the processes started by UFT will inherit it (You need to make sure that your AUT is a child process of UFT). You can use WINAPI functions via the Extern.Declare headers.
We should not forget that such practices are considered malware - doesn't matter the honest purpose - so if you really want to stay clean, make your work transparent, comply to security rules; and most of all, you have UFT - do it via the GUI as the normal user would do it.

Re-render/refresh application on runtime

I have the following question:
I have an application that I'm using Marionette.Layout and this Layout has regions.
I want to add the option to the user to change language(on run time), meaning after the application is already render and the user is working, he can change the language and all the application should be change it to the selected language.
My Question:
1. I need to 'refresh/re-render' all the application, how is this done, I didn't found or I miss it, how to re-render the application?
I already have a a mechanism that the 'templates' are like:
https://github.com/janl/mustache.js/issues/216
This is working when the application is started, the first time, I need on run time to re-render/refresh with the new data
Unfortunately there isn't anything in the Marionette to do this for you. You will have to write the code to re-render the entire application with the new language setting, yourself.

How to use internationalization in Label fields in Screens in Oracle Policy Automation

I am very new to Oracle Policy Automation. I am developing a screen which will give the option to the user to select languages. Based on his/her selection, the next screen should display a welcome message in the language selected.
I have two properties files (one for each language) and I have placed them inside the /classes/configuration folder.
Now, my query is how to invoke these properties files based on user selection and what should I write in the label field so that the messages are dynamically picked up.
Thanks in advance for the help.
I guess you may have figured this out by now.
In OPA the locale has to be set at the start of an interactive session (part of the start investigation URL) and cannot be changed subsequently. The locale specific resource files under configuration will then be used.
Your locale selection screen would probably need to be outside of OPA triggering a session start of the correct type. If you are using OWD then it will actually provide it's own locale selection screen if you try to access a rulebase without specifying the locale to use. We are working on some additional tooling around OWD to make this process a lot more straightforward

QTP: Unique browser identificator not related to title?

In my QTP keywrord driven automation, I would like to open browser and then automatically call all functions on that browser. I noticed it does work even when the browser title changes but I am not sure whether its coincidence or not.
I would need to open browser with e.g. ID and then simply call Browser("MyID"). functions. Is there any way or I can rely on QTP even when the browser changes its name?
QTP doesn't use the title to identify the browser, the description usually is based on when the browser was created (see the Creation Time ordinal identifier). So if the state of your machine is the same (no other browsers were open before beginning to test) then the identification should be consistent.
During your testing, if there's only one Browser window open all the time , then
Just adding a "Browser" object in your OR , without any identification property would work.
If there are multiple browsers open, then you might have to add one or more of
Name
Title
Creation time.
Avoid using Creation time though.

How can a bookmarklet access a Firefox extension (or vice versa)

I have written a Firefox extension that catches when a particular URL is entered and does some stuff. My main app launches Firefox with this URL. The URL contains sensitive information so I don't want it being stored in the history.
I'm concerned about the case where the extension is not installed. If its not installed and Firefox gets launched with the sensitive URL, it will get stored in history and there's nothing I can do about it. So my idea is to use a bookmarklet.
I will launch Firefox with "javascript:window.location.href='pleaseinstallthisplugin.html'; sensitiveinfo='blahblah'".
If the extension is not installed they will get redirected to a page that tells them to install it and the sensitive info won't get stored in the history. If the extension IS installed it will grab the information in the sensitiveinfo variable and do its thing.
My question is, can the bookmarklet call a method in the extension to pass the sensitive info (and if so, how) or can the extension catch when javascript is being called in the bookmarklet?
How can a bookmarklet and Firefox extension communicate?
p.s. The alternative means of getting around this situation would be for my main app to launch Firefox and communicate with the extension using sockets but I am loath to do that because I've run into too many issues over the years with users with crazy firewalls blocking socket communication. I'd like to do everything without sockets if possible.
As far as I know, bookmarklets can never access chrome files (extensions).
Bookmarklets are executed in the scope of the current document, which is almost always a content document. However, if you are passing it in via the command line, it seems to work:
/Applications/Namoroka.app/Contents/MacOS/firefox-bin javascript:alert\(Components\)
Accessing Components would throw if it was not allowed, but the alert displays the proper object.
You could use unsafeWindow to inject a global. You can add a mere property so that your bookmarklet only needs to detect whether the global is defined or not, but you should know that, as far as I know, there is no way to prohibit sites in a non-bookmarklet context from also sniffing for this same global (since it may be a privacy concern to some that sites can detect whether they are using the extension). I have confirmed in my own add-on which injects a global in a manner similar to that below that it does work in a bookmarklet as well as regular site context.
If you register an nsIObserver, e.g., where content-document-global-created is the topic, and then unwrap the subject, you can inject your global (see this if you need to inject something more sophisticated like an object with methods).
Here is some (untested) code which should do the trick:
var observerService = Cc['#mozilla.org/observer-service;1'].getService(Ci.nsIObserverService);
observerService.addObserver({observe: function (subject, topic, data) {
var unsafeWindow = XPCNativeWrapper.unwrap(subject);
unsafeWindow.myGlobal = true;
}}, 'content-document-global-created', false);
See this and this if you want an apparently easier way in an SDK add-on (not sure whether SDK postMessage communication would work as an alternative but with the apparently same concern that this would be exposed to non-bookmarklet contexts (i.e., regular websites) as well).

Resources