This chapter explains the following subjects:
- Language Support
- Loading GS Script Dynamically
- Passing Multiple Parameter Objects
- Combining Gigya Services
The Gigya platform supports localization. Gigya's default language is English. You may change the language to one of the supported languages by assigning a string language code to the lang field of the global configuration object.
However, for best results and to avoid having to reload assets, when possible, you should add the lang param directly to the actual request to the gigya.js file, like so:
|Chinese (Hong Kong)||zh-hk|
|Hindi (*SMS TFA Only)||hi|
|Kannada (*SMS TFA Only)||kn|
|Marathi (*SMS TFA Only)||mr|
Localization Support for Third-Party Plugins
Most of Gigya's plugins support localization based on the lang parameter in the global configuration object, as described in the previous section. However, for some third-party plugins, such as Facebook's Like button, you have to set the parameter before the plugin is loaded. In such cases, the language needs to be set in the socialize JS URL, which is loaded before the plugin's parameters are initiated.
To support localization for third-party plugins, including Facebook's Like button, add a new query parameter to the socialize JS URL with "lang=" and the code of the desired language. The format of the "lang" query parameter is a 2-letter language code with a 2-letter country code, separated by a hyphen.
Recommended Best Practice example:
Recommended Best Practice for implementing the lang parameter is to append it to the string that loads the gigya.js SDK (as in the above example), rather than including it within the global Conf object.
In this example the language is set to Japanese, with the 2-letter language code 'ja' representing Japanese, and the 2-letter country code 'jp' representing Japan.
Managing Screen-Set Locales
For instructions on how to manage and edit the locales available to your site's screen-sets, see UI Builder Localization.
Loading Gigya's Script Dynamically
The Gigya service allows loading its JS script dynamically using document.write, or DOM manipulation.
This can be useful in case your web-page uses Gigya only in some circumstances, and it might be more efficient to load gigya.js only if needed.
Step 1 - Load Gigya's Script
Method A - Using document.write:
The document.write method can be activated only while loading the page. The implication of choosing method A is that you must decide while loading the page whether to load gigya.js or not. This decision can be done on the server side.
Method B - DOM Manipulation:
Using this method, you can load gigya.js when the page is already displayed.
Step 2 - Receive Notification when Gigya's Script has Finished Loading
onGigyaServiceReady is a variable that the Gigya WebSDK always checks for as soon as it completes loading.
For Gigya methods to function properly, they can only be called after the Gigya WebSDK finishes loading completely. Attempting to call a method prior to this, will result in an error similar to the following:
To ensure that Gigya is always loaded prior to any method calls on your page, you can place all Gigya related functions inside a handler and then call that handler using the onGigyaServiceReady variable.
A code example follows:
Using the above example, after Gigya finishes loading, it will then call the onGigyaServiceReady function which will, in turn, call the GigyaLoadFunctions function.
The Example Code:
Passing Multiple Parameter Objects
Currently our API methods are called only with params , but we support calling our API methods with multiple arguments. The arguments passed to the method are merged into a single params object. If a property is defined in several objects, the latest argument property will override the previous one.
In the following example five parameter objects are defined:
If you now call a method with three parameter objects (arguments), they will merge to form one. For example, if you call gigya.socialize.showLoginUI(socializeConfig,params1,params2), the merged params objects that the method will use is:
Another example, if you call gigya.gm.showUserStatusUI(gmConfig, params2), the two parameter objects merge into the following params object that the method will use:
Combining Gigya Services
Gigya offers the option for partners to combine services in order to reduce requests to the server.
You can list the services you may want to use later and load them in advance, and in this way you save requests to the server.
It is done by adding a "services" query string parameter to gigya.js, which can accept a comma-separated list of predefined services to load in gigya.js.
Each service is defined as follows: [service name].[plugin name]. The following is the complete list of services that may be loaded:
Each of these is a service. You can add the comma-separated list of predefined services to load in gigya.js in the following manner:
When using Gigya's API's over HTTPS it is important that the script tag in the <head> of your pages reference the HTTPS version of the JS SDK, (note CDNS as opposed to CDN) e.g.,
When combining services, all pages that load gigya.js must load the same list of services. For example, if one page loads accounts.screenSet, all pages must load accounts.screenSet.