Skip to content

Commit 525c0c9

Browse files
authored
Merge pull request #155 from hellosign/develop
Add support for more languages
2 parents 77c8b06 + c9ce102 commit 525c0c9

4 files changed

Lines changed: 31 additions & 34 deletions

File tree

‎src/embedded.js‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class HelloSign extends Emitter {
255255
* Validates and appends the "user_culture" parameter to
256256
* the iFrame params object.
257257
*
258-
* @throws {TypeError} if locale is invalid
258+
* @throws {TypeError} if locale is not a string
259259
* @param {URLSearchParams} params
260260
* @private
261261
*/
@@ -266,13 +266,6 @@ class HelloSign extends Emitter {
266266
throw new TypeError('"locale" must be a string');
267267
}
268268

269-
// Object.values() has been polyfilled, eslint-compat
270-
// need not raise an exception for it.
271-
// eslint-disable-next-line
272-
if (!Object.values(settings.locales).includes(val)) {
273-
throw new TypeError(`"${val}" is not a supported locale`);
274-
}
275-
276269
params.append('user_culture', val);
277270
}
278271

‎src/embedded.test.js‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,6 @@ describe('HelloSign', () => {
315315
}).toThrow(/"locale" must be a string/);
316316
});
317317

318-
test('throws if "locale" is not supported', () => {
319-
client = new HelloSign({ clientId: mockClientId });
320-
321-
expect(() => {
322-
client.open(mockSignURL, {
323-
locale: 'Mars',
324-
});
325-
}).toThrow(/"Mars" is not a supported locale/);
326-
});
327-
328318
test('appends default value for "user_culture" to the iFrame URL if "locale" is not specified', (done) => {
329319
client = new HelloSign({ clientId: mockClientId });
330320

@@ -346,12 +336,12 @@ describe('HelloSign', () => {
346336
const url = new URL(data.url);
347337

348338
expect(url.searchParams.has('user_culture')).toBe(true);
349-
expect(url.searchParams.get('user_culture')).toBe('zh_CN');
339+
expect(url.searchParams.get('user_culture')).toBe('zh-CN');
350340
done();
351341
});
352342

353343
client.open(mockSignURL, {
354-
locale: 'zh_CN',
344+
locale: 'zh-CN',
355345
});
356346
});
357347

‎src/sass/embedded.scss‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
top: 0;
1010
left: 0;
1111
width: 100%;
12+
13+
// Default z-index. This can be overridden by extending
14+
// this class in your own sylesheet.
15+
z-index: 9997;
1216
}
1317
}
1418

‎src/settings.js‎

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,30 @@ const iframe = {
5252
* @readonly
5353
*/
5454
const locales = {
55-
CS_CZ: 'cs_CZ', // Czech (Czech Republic)
56-
DA_DK: 'da_DK', // Danish (Denmark)
57-
DE_DE: 'de_DE', // German (Germany)
58-
EN_US: 'en_US', // English (United States)
59-
ES_ES: 'es_ES', // Spanish (Spain)
60-
ES_MX: 'es_MX', // Spanish (Mexico)
61-
FR_FR: 'fr_FR', // French (France)
62-
IT_IT: 'it_IT', // Italian (Italy)
63-
JA_JP: 'ja_JP', // Japanese (Japan)
64-
NL_NL: 'nl_NL', // Dutch (Netherlands)
65-
PL_PL: 'pl_PL', // Polish (Poland)
66-
PT_BR: 'pt_BR', // Portuguese (Brazil)
67-
SV_SE: 'sv_SE', // Swedish (Sweden)
68-
ZH_CN: 'zh_CN', // Chinese (Simplified) (China)
55+
CS_CZ: 'cs-CZ', // Czech (Czech Republic)
56+
DA_DK: 'da-DK', // Danish (Denmark)
57+
DE_DE: 'de-DE', // German (Germany)
58+
EN_GB: 'en-GB', // English (United Kingdom)
59+
EN_US: 'en-US', // English (United States)
60+
ES_LA: 'es-LA', // Spanish (Latin America)
61+
ES_ES: 'es-ES', // Spanish (Spain)
62+
ES_MX: 'es-MX', // Spanish (Mexico)
63+
FR_FR: 'fr-FR', // French (France)
64+
ID_ID: 'id-ID', // Indonesian (Indonesia)
65+
IT_IT: 'it-IT', // Italian (Italy)
66+
JA_JP: 'ja-JP', // Japanese (Japan)
67+
KO_KR: 'ko-KR', // Korean (Korea)
68+
MS_MY: 'ms-MY', // Malaysian (Malaysia)
69+
NB_NO: 'nb-NO', // Norwegian (Norway)
70+
NL_NL: 'nl-NL', // Dutch (Netherlands)
71+
PL_PL: 'pl-PL', // Polish (Poland)
72+
PT_BR: 'pt-BR', // Portuguese (Brazil)
73+
RU_RU: 'ru-RU', // Russian (Russia)
74+
SV_SE: 'sv-SE', // Swedish (Sweden)
75+
TH_TH: 'th-TH', // Thai (Thailand)
76+
UK_UA: 'uk-UA', // Ukrainian (Ukraine)
77+
ZH_CN: 'zh-CN', // Chinese (Simplified) (China)
78+
ZH_TW: 'zh-TW', // Chinese (Traditional) (China)
6979
};
7080

7181
/**

0 commit comments

Comments
 (0)