Skip to content

dx 2896 fallback locale update #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [v1.21.1](https://github.com/contentstack/contentstack-management-javascript/tree/v1.21.1) (2025-05-12)
- Fix
- Fixed unexpected fallback_locale behavior during direct locale updates.

## [v1.21.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.21.0) (2025-05-05)
- Enhancement
- Region support added
Expand Down
7 changes: 6 additions & 1 deletion lib/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ export const update = (http, type, params = {}) => {
delete json.deleted_at
delete json.updated_at
delete json.updated_by
delete json.updated_at

// If param has data for this entity type, merge it with the json object
if (param && param[type]) {
Object.assign(json, param[type])
}

if (type) {
updateData[type] = json
if (type === 'entry') updateData[type] = cleanAssets(updateData[type])
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/management",
"version": "1.21.0",
"version": "1.21.1",
"description": "The Content Management API is used to manage the content of your Contentstack account",
"main": "./dist/node/contentstack-management.js",
"browser": "./dist/web/contentstack-management.js",
Expand Down
2 changes: 1 addition & 1 deletion sanity-report.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fs from 'fs'

dotenv.config()

const mochawesomeJsonOutput = fs.readFileSync('./mochawesome-report/mochawesome.json', 'utf-8')
const mochawesomeJsonOutput = fs.readFileSync('./mochawesome-report/mochawesome.json', 'utf8')
const mochawesomeReport = JSON.parse(mochawesomeJsonOutput)
const report = `./mochawesome-report/sanity-report.html`

Expand Down
23 changes: 20 additions & 3 deletions test/sanity-check/api/locale-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ describe('Locale api Test', () => {
.catch(done)
})

it('should get and update a language Hindi - India', done => {
it('should get and update a language Hindi - India with fallback locale en-at', done => {
makeLocale('hi-in')
.fetch()
.then((locale) => {
locale.fallback_locale = 'en-at'
return locale.update()
// locale.fallback_locale = 'en-at'
return locale.update({ locale: { fallback_locale: 'en-at' } })
})
.then((locale) => {
expect(locale.code).to.be.equal('hi-in')
Expand All @@ -111,6 +111,23 @@ describe('Locale api Test', () => {
.catch(done)
})

it('should get and update a language Hindi - India with fallback locale en-us', done => {
makeLocale('hi-in')
.fetch()
.then((locale) => {
locale.fallback_locale = 'en-us'
return locale.update()
})
.then((locale) => {
expect(locale.code).to.be.equal('hi-in')
expect(locale.name).to.be.equal('Hindi - India')
expect(locale.fallback_locale).to.be.equal('en-us')
expect(locale.uid).to.be.not.equal(null)
done()
})
.catch(done)
})

it('should delete language: Hindi - India', done => {
makeLocale('mr-in')
.delete()
Expand Down
Loading