Skip to content

Commit 2ebd2b2

Browse files
Merge pull request #115 from contentstack/development
HOTFIX | 16-01-2025 | setLocale
2 parents d004994 + 138b316 commit 2ebd2b2

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)