You can specify a user's language in the Web SDK using one of the following methods:
During SDK Initialization: Include the
Languagetag within thetagsobject in yourinitcall. 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
setLanguagefunction: After the SDK has been initialized, you can use thesetLanguageAPI 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
Languagetag is generally recommended for segmentation purposes, whilesetLanguagedirectly influences SDK behavior related to language.
Comments
0 comments
Please sign in to leave a comment.