Skip to content

Commit 1baea0c

Browse files
committed
feat: Avoid defaulting to English if locale is not set
If `locale" is not specified, we prefer to honor an Embedded user's default browser language setting (if it is supported by our web app) instead of always forcing users into viewing our web app in English. Our backend now allows the `user_culture` param to be optional, and if it is blank or omitted then it will tell the web app to prefer the user's default browser language. Also in this feat: - Update tests - Simplify test mock GUIDs - Correct a few comments
1 parent c9ce102 commit 1baea0c

4 files changed

Lines changed: 92 additions & 107 deletions

File tree

‎src/defaults.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import settings from './settings';
2-
31
export default {
42
allowCancel: true,
53
debug: false,
6-
locale: settings.locales.EN_US,
74
skipDomainVerification: false,
85
testMode: false,
96
timeout: 30000, // 30 seconds

‎src/embedded.js‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,21 +252,23 @@ class HelloSign extends Emitter {
252252
}
253253

254254
/**
255-
* Validates and appends the "user_culture" parameter to
256-
* the iFrame params object.
255+
* Appends the "user_culture" parameter to the iFrame
256+
* params object if it is defined.
257257
*
258-
* @throws {TypeError} if locale is not a string
259258
* @param {URLSearchParams} params
260259
* @private
261260
*/
262261
_applyLocale(params) {
263262
const val = this._config.locale;
264263

265-
if (typeof val !== 'string') {
266-
throw new TypeError('"locale" must be a string');
264+
// If "locale" is not defined, then the "user_culture"
265+
// param is not sent to the app. This tells the app to
266+
// try use the user's default browser language, if it
267+
// is supported by HelloSign. Otherwise, the app falls
268+
// back to English.
269+
if (val && val.length) {
270+
params.append('user_culture', val);
267271
}
268-
269-
params.append('user_culture', val);
270272
}
271273

272274
/**

0 commit comments

Comments
 (0)