You can specify a user's language in the Web SDK using one of the following methods:
During SDK Initialization: Include the
Language
tag within thetags
object in yourinit
call. This value will be associated with the user's profile.Pushwoosh.push(['init', { logLevel: 'debug', // Or your preferred log level applicationCode: 'YOUR_APPLICATION_CODE', safariWebsitePushID: 'web.your.domain.identifier', // For Safari defaultNotificationTitle: 'Your Default Title', defaultNotificationImage: 'https://example.com/default-image.png', autoSubscribe: true, userId: your_user_id_variable, // Optional: Your internal user ID // ... other init parameters tags: { 'Language': 'your_language_code' // e.g., 'en', 'fr', 'es' } }]);
Replace
'your_language_code'
with the desired ISO 639-1 language code (e.g., 'en' for English, 'es' for Spanish) obtained from your application's settings.Using the
setLanguage
function: After the SDK has been initialized, you can use thesetLanguage
API call to update the language. This function specifically sets the language for the device, which can be used for localization of system messages or campaigns targeted by language.Pushwoosh.push(function(api) { api.setLanguage('your_language_code'); // e.g., 'en', 'fr', 'es' });
This will update the language for the current user/device. Using the
Language
tag is generally recommended for segmentation purposes, whilesetLanguage
directly influences SDK behavior related to language.
Comments
0 comments
Please sign in to leave a comment.