registerControl(control: PP.Ui.Control);
control. Control to be registered in the resources manager.
The registerControl method registers a control in resources manager.
When the current language is changed, the resource manager automatically performs localization of the control.
To execute the example, create an HTML page and in the <head> tag add links to the PP.js and PP.css files. Parent directory for the current root folder must contain resources folder named "resources". Load resources for Russian and English language to the page, and add a button with specified resource key:
// Specify the path to the root folder containing files of resources PP.resourceManager.setRootResourcesFolder("../resources/", False); // Set the path of the service controlling resources PP.resourceManager.setResourceHandler("PPService.axd?action=pack"); // Load resources for Russian and English PP.resourceManager.load("PP, Express", PP.Cultures.ru); PP.resourceManager.load("PP, Express", PP.Cultures.en); // Create a button var button = new PP.Ui.Button({ Width: 70, Height: 22, }); // Add the button to document document.body.appendChild(button.getDomNode()); // Set Russian as a current language PP.setCurrentCulture(PP.Cultures.ru); // Set resource key for the button button._ResourceKey = "wCancel"; // Register the button in the resource manager PP.resourceManager.registerControl(button);
After executing the example resources for Russian and English are loaded to the page, and a button with the wCancel resource key is also added to the page:
Set English as a current language and refresh all controls registered in the resource manager:
// Set English as a current language PP._currentCulture = PP.Cultures.en; // Refresh all controls registered in the resource manager PP.resourceManager.refreshControls();
After executing the specified script, text in the button is automatically translated into English:
See also: