Skip to content

Commit 70a5679

Browse files
v6.3.0 (#113)
* Update: v6.3.0, added setLocale method
1 parent b415143 commit 70a5679

File tree

12 files changed

+2386
-2458
lines changed

12 files changed

+2386
-2458
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const numberTrait = new UserTrait('age', 25);
102102
const booleanTrait = new UserTrait('isPremium', true);
103103
const dateTrait = new UserTrait('lastLogin', new Date());
104104
const timeIntervalTrait = new UserTrait('timeOfPurchase', new Date());
105+
Survicate.setLocale('en-US');
105106
const listener: SurvicateEventListener = {
106107
onSurveyDisplayed(event: SurveyDisplayedEvent) {},
107108
onQuestionAnswered(event: QuestionAnsweredEvent) {},

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ repositories {
120120
dependencies {
121121
//noinspection GradleDynamicVersion
122122
implementation 'com.facebook.react:react-native:+' // From node_modules
123-
implementation ('com.survicate:survicate-sdk:6.2.0')
123+
implementation ('com.survicate:survicate-sdk:6.3.0')
124124
}
125125

126126
if (isNewArchitectureEnabled()) {

android/src/main/java/com/survicate/react/SurvicateModuleImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,12 @@ public void removeListeners(int count) {
127127
public void removeListeners(double count) {
128128
removeListeners((int) count);
129129
}
130+
131+
@ReactMethod
132+
public void setLocale(String locale) {
133+
if (!isInitialized) {
134+
return;
135+
}
136+
Survicate.setLocale(locale);
137+
}
130138
}

android/src/oldarch/java/com/survicate/react/SurvicateModule.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ public SurvicateModule(@NonNull ReactApplicationContext reactContext) {
2020
public abstract void initializeSdk();
2121
public abstract void reset();
2222
public abstract void setWorkspaceKey(String workspaceKey);
23+
public abstract void setLocale(String locale);
2324
}

example/react_native/yarn.lock

Lines changed: 740 additions & 754 deletions
Large diffs are not rendered by default.

ios/SurvicateBindings.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ - (dispatch_queue_t)methodQueue
5454
[[SurvicateSdk shared] setWorkspaceKey:workspaceKey error: &error];
5555
}
5656

57+
RCT_EXPORT_METHOD(setLocale:(NSString *)locale)
58+
{
59+
[[SurvicateSdk shared] setLocale:locale];
60+
}
5761

5862
- (NSArray<NSString*> *)supportedEvents {
5963
return @[@"onQuestionAnswered", @"onSurveyClosed", @"onSurveyCompleted", @"onSurveyDisplayed"];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@survicate/react-native-survicate",
33
"title": "React Native Survicate Bindings",
4-
"version": "6.2.0",
4+
"version": "6.3.0",
55
"description": "React Native bindings for Survicate Mobile SDK",
66
"main": "lib/commonjs/index.js",
77
"module": "lib/module/index.js",

react-native-survicate.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Pod::Spec.new do |s|
2121
s.requires_arc = true
2222

2323
s.dependency "React"
24-
s.dependency "Survicate", "6.2.0"
24+
s.dependency "Survicate", "6.3.0"
2525
# ...
2626
# s.dependency "..."
2727

src/NativeSurvicateModule.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface Spec extends TurboModule {
1212
reset(): void;
1313
addListener(eventName: string): void;
1414
removeListeners(count: number): void;
15+
setLocale(locale: string): void;
1516
}
1617

1718
export default TurboModuleRegistry.get<Spec>("SurvicateBindings");

src/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,22 @@ class Survicate {
140140
onSurveyClosedListener.remove();
141141
};
142142
}
143+
144+
/**
145+
* Sets the preferred locale used for survey translations and targeting filters.
146+
* The specified locale takes priority over the device's default locale.
147+
*
148+
* This method affects only the Survicate SDK and does not change in any way the app locale settings.
149+
*
150+
* @param languageTag An IETF language tag such as:
151+
* - Two-letter ISO 639 language code (e.g., "en", "fr")
152+
* - Three-letter ISO 639 language code for languages without the two-letter code (e.g., "haw", "yue")
153+
* - Language with region (e.g., "en-US", "pt-BR")
154+
* - Language with script (e.g., "zh-Hans")
155+
*/
156+
static setLocale(languageTag: string): void {
157+
survicate.setLocale(languageTag);
158+
}
143159
}
144160

145161
export class UserTrait {

0 commit comments

Comments
 (0)