@@ -17,7 +17,7 @@ public class DbxRequestConfig {
1717 private final HttpRequestor httpRequestor ;
1818 private final int maxRetries ;
1919
20- private DbxRequestConfig (String clientIdentifier , /*@Nullable*/ String userLocale , HttpRequestor httpRequestor , int maxRetries ) {
20+ private DbxRequestConfig (String clientIdentifier , /*@Nullable*/ String userLocale , HttpRequestor httpRequestor , int maxRetries ) {
2121 if (clientIdentifier == null ) throw new NullPointerException ("clientIdentifier" );
2222 if (httpRequestor == null ) throw new NullPointerException ("httpRequestor" );
2323 if (maxRetries < 0 ) throw new IllegalArgumentException ("maxRetries" );
@@ -28,11 +28,28 @@ private DbxRequestConfig(String clientIdentifier, /*@Nullable*/String userLocale
2828 this .maxRetries = maxRetries ;
2929 }
3030
31- public DbxRequestConfig (String clientIdentifier , String userLocale ) {
31+ /**
32+ * Creates a new configuration.
33+ *
34+ * @param clientIdentifier client identifier typically in the form "Name/Version" to be used in
35+ * the User-Agent header (see {@link #getClientIdentifier}).
36+ * @param userLocale IETF BCP 47 language tag of locale to use for user-visible text in responses, or
37+ * {@code null} to use the user's Dropbox locale preference.
38+ */
39+ public DbxRequestConfig (String clientIdentifier , /*@Nullable*/ String userLocale ) {
3240 this (clientIdentifier , userLocale , StandardHttpRequestor .INSTANCE );
3341 }
3442
35- public DbxRequestConfig (String clientIdentifier , /*@Nullable*/ String userLocale , HttpRequestor httpRequestor ) {
43+ /**
44+ * Creates a new configuration.
45+ *
46+ * @param clientIdentifier client identifier typically in the form "Name/Version" to be used in
47+ * the User-Agent header (see {@link #getClientIdentifier}).
48+ * @param userLocale IETF BCP 47 language tag of locale to use for user-visible text in responses, or
49+ * {@code null} to use the user's Dropbox locale preference.
50+ * @param httpRequestor HTTP client to use for issuing requests.
51+ */
52+ public DbxRequestConfig (String clientIdentifier , /*@Nullable*/ String userLocale , HttpRequestor httpRequestor ) {
3653 this (clientIdentifier , userLocale , httpRequestor , 0 );
3754 }
3855
@@ -67,17 +84,15 @@ public String getClientIdentifier() {
6784 }
6885
6986 /**
70- * Returns the locale of the user of your app. This is used by the Dropbox server to localize
71- * user-visible strings returned by API calls.
87+ * Returns the locale of the user of your app as an IETF BCP 47 language tag. This is used by
88+ * the Dropbox server to localize user-visible strings returned by API calls.
7289 *
73- * <p>
74- * If the value is {@code null} or some locale that Dropbox doesn't support, the localized
75- * strings will be in English.
76- * </p>
90+ * <p> If the value is {@code null} or some locale that Dropbox doesn't support, the strings
91+ * will be localized based on the user's Dropbox locale preference.
7792 *
7893 * <p> Defaults to {@code null}.
7994 *
80- * @return locale of app user, or {@code null} if not localized .
95+ * @return locale of app user, or {@code null} to use user's Dropbox locale settings .
8196 */
8297 public String getUserLocale () {
8398 return userLocale ;
@@ -190,26 +205,45 @@ private Builder(String clientIdentifier) {
190205 * Set the locale of the app user. User-visible messages returned by the Dropbox servers
191206 * will be localized to this locale.
192207 *
193- * <p> Defaults to {@code null}, which disables localization (messages will be in English).
208+ * <p> Defaults to {@code null}, which means strings will be localized according to the
209+ * user's Dropbox locale preference.
210+ *
211+ * @param userLocale locale of app user as an IETF BCP 47 language tag, or {@code null} to
212+ * use the user's Dropbox locale settings.
194213 *
195- * @param userLocale Locale of app user, or {@code null} to disable localization
196214 * @return this builder
197215 */
198216 public Builder withUserLocale (/*@Nullable*/ String userLocale ) {
199217 this .userLocale = userLocale ;
200218 return this ;
201219 }
202220
221+ /**
222+ * Set the locale of user-visible messages returned by the Dropbox servers to the user's
223+ * Dropbox locale.
224+ *
225+ * <p> User-visible strings will be localized according to the user's Dropbox locale
226+ * preference.
227+ *
228+ * @return this builder
229+ */
230+ public Builder withUserLocaleFromPreferences () {
231+ this .userLocale = null ;
232+ return this ;
233+ }
234+
203235 /**
204236 * Set the locale of the app user. User-visible messages returned by the Dropbox servers
205237 * will be localized to this locale.
206238 *
207- * <p> Defaults to {@code null}, which disables localization (messages will be in English).
239+ * <p> Defaults to {@code null}, which means strings will be localized according to the
240+ * user's Dropbox locale preference.
241+ *
242+ * @param userLocale Locale of app user, or {@code null} to use user's Dropbox locale settings.
208243 *
209- * @param userLocale Locale of app user, or {@code null} to disable localization
210244 * @return this builder
211245 */
212- public Builder withUserLocale (/*@Nullable*/ Locale userLocale ) {
246+ public Builder withUserLocaleFrom (/*@Nullable*/ Locale userLocale ) { // not named withUserLocale because of ambiguous calls when passing 'null'
213247 this .userLocale = userLocale == null ? null : userLocale .toLanguageTag ();
214248 return this ;
215249 }
0 commit comments