@@ -111,6 +111,7 @@ public class Leanplum {
111111 private static LeanplumDeviceIdMode deviceIdMode = LeanplumDeviceIdMode .MD5_MAC_ADDRESS ;
112112 private static String customDeviceId ;
113113 private static String customAppVersion = null ;
114+ private static String customLocale = null ;
114115 private static boolean userSpecifiedDeviceId ;
115116 private static boolean locationCollectionEnabled = true ;
116117 private static volatile boolean pushDeliveryTrackingEnabled = true ;
@@ -328,6 +329,17 @@ public static void setDeviceId(String deviceId) {
328329 userSpecifiedDeviceId = true ;
329330 }
330331
332+ /**
333+ * Sets a custom locale. You should call this before {@link Leanplum#start}.
334+ */
335+ public static void setLocale (String locale ) {
336+ if (TextUtils .isEmpty (locale )) {
337+ Log .i ("setLocale - Empty locale parameter provided." );
338+ }
339+
340+ customLocale = locale ;
341+ }
342+
331343 /**
332344 * Gets the deviceId in the current Leanplum session. This should only be called after
333345 * {@link Leanplum#start}.
@@ -666,6 +678,11 @@ private static void startHelper(
666678 versionName = "" ;
667679 }
668680
681+ String locale = Util .getLocale ();
682+ if (!TextUtils .isEmpty (customLocale )) {
683+ locale = customLocale ;
684+ }
685+
669686 TimeZone localTimeZone = TimeZone .getDefault ();
670687 Date now = new Date ();
671688 int timezoneOffsetSeconds = localTimeZone .getOffset (now .getTime ()) / 1000 ;
@@ -698,7 +715,7 @@ private static void startHelper(
698715 }
699716 params .put (Constants .Keys .TIMEZONE , localTimeZone .getID ());
700717 params .put (Constants .Keys .TIMEZONE_OFFSET_SECONDS , Integer .toString (timezoneOffsetSeconds ));
701- params .put (Constants .Keys .LOCALE , Util . getLocale () );
718+ params .put (Constants .Keys .LOCALE , locale );
702719 params .put (Constants .Keys .COUNTRY , Constants .Values .DETECT );
703720 params .put (Constants .Keys .REGION , Constants .Values .DETECT );
704721 params .put (Constants .Keys .CITY , Constants .Values .DETECT );
0 commit comments