Skip to content

Commit 138b316

Browse files
Merge pull request #114 from contentstack/fix/dx-2008-setLocale-issue
fix/dx 2008 set locale issue
2 parents 6d43366 + 391b1f7 commit 138b316

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/lib/contentstack.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export function stack(config: StackConfig): StackClass {
5959
throw new Error('Environment for Stack is required');
6060
}
6161

62+
if (config.locale) {
63+
defaultConfig.params.locale = config.locale;
64+
}
65+
6266
if (config.live_preview) {
6367
if (Utility.isBrowser()) {
6468
const params = new URL(document.location.toString()).searchParams;

src/lib/stack.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export class Stack {
114114
*/
115115
setLocale(locale: string) {
116116
this.config.locale = locale;
117+
this._client.defaults.params.locale = locale;
117118
}
118119

119120
/**

test/unit/stack.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ describe('Stack class tests', () => {
3232
});
3333

3434
stack = new Stack(client, config() as StackConfig);
35+
client.defaults.params = {};
3536
});
3637
it('should test import of class Stack', (done) => {
3738
expect(stack).toBeInstanceOf(Stack);

0 commit comments

Comments
 (0)