load(resourcesList: String, cultureInfo: PP.CultureInfo, callback: PP.Delegate|function);
resNamesArray. List of resource files' names separated with commas (the leftmost part of the file name must be specified).
cultureInfo. Language and regional parameters.
callback. Callback function.
The load method loads resources files as a string with file names separated with commas.
To execute the example, create an HTML page, and add a link to the PP.js file in the <head> tag. Parent directory for the current root folder must contain resources folder named "resources". Load resource files with the leftmost part PP for Russian and English language on the page, by executing the following script in the browser console:
// Create resource manager object var resourceManager = new PP.ResourceManager(); PP.resourceManager = resourceManager; // Specify path to root folder that contains resource files resourceManager.setRootResourcesFolder("../resources/", False); resourceManager.load("PP", PP.Cultures.ru, function () { console.log("Resource files for Russian language are loaded"); }); resourceManager.load("PP", PP.Cultures.en, function () { console.log("Resource files for English language are loaded"); });
After executing the example the browser console displays notification on loading resource files for Russian and English languages. Check it by running the following scenario:
var userProc = function () { // Select Russian as the current language PP.setCurrentCulture(PP.Cultures.ru); // Get a line by the key dateTimeEditMonthNames1 for Russian language var str1 = resourceManager.getString("dateTimeEditMonthNames1"); if (str1 != "") { console.log("Line by the key dateTimeEditMonthNames1 for Russian language: " + str1); } else { console.log("Line by the key dateTimeEditMonthNames1 for Russian language is not determined"); }; // Make English the current language PP.setCurrentCulture(PP.Cultures.en); // Get the line by the key dateTimeEditMonthNames1 for English language var str2 = resourceManager.getString("dateTimeEditMonthNames1"); if (str2 != "") { console.log("Line by the key dateTimeEditMonthNames1 for English language: " + str2); } else { console.log("Line by the key dateTimeEditMonthNames1 for English language is not determined"); }; } // Determine the line by the key dateTimeEditMonthNames1 in various languages userProc();
After example execution the browser console displays the value that corresponds to the resource key dateTimeEditMonthNames1 for Russian and English languages:
Line by the key dateTimeEditMonthNames1 for Russian language: January
String by the dateTimeEditMonthNames1 key for English locale: January
See also: