Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: formatjs/formatjs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @formatjs/cli@6.4.0
Choose a base ref
...
head repository: formatjs/formatjs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @formatjs/cli@6.4.2
Choose a head ref
  • 4 commits
  • 7 files changed
  • 1 contributor

Commits on Jan 17, 2025

  1. Copy the full SHA
    ddca2c2 View commit details
  2. build: publish

     - @formatjs/cli-lib@7.1.1
     - @formatjs/cli@6.4.1
    longlho committed Jan 17, 2025
    Copy the full SHA
    d9deb01 View commit details
  3. Copy the full SHA
    144453a View commit details
  4. build: publish

     - @formatjs/cli-lib@7.1.2
     - @formatjs/cli@6.4.2
    longlho committed Jan 17, 2025
    Copy the full SHA
    079ede0 View commit details
12 changes: 12 additions & 0 deletions packages/cli-lib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [7.1.2](https://github.com/formatjs/formatjs/compare/@formatjs/cli-lib@7.1.1...@formatjs/cli-lib@7.1.2) (2025-01-17)

### Bug Fixes

* **@formatjs/cli-lib:** fix flatten during structural equality check ([144453a](https://github.com/formatjs/formatjs/commit/144453a7a91af42678cb3c5b57d31673ef72b9cc)) - by @longlho

## [7.1.1](https://github.com/formatjs/formatjs/compare/@formatjs/cli-lib@7.1.0...@formatjs/cli-lib@7.1.1) (2025-01-17)

### Bug Fixes

* **@formatjs/cli-lib:** handle parsing error during verification ([ddca2c2](https://github.com/formatjs/formatjs/commit/ddca2c22899ce698f945927a35df6126c8cdbc48)) - by @longlho

# [7.1.0](https://github.com/formatjs/formatjs/compare/@formatjs/cli-lib@7.0.3...@formatjs/cli-lib@7.1.0) (2025-01-17)

### Features
2 changes: 1 addition & 1 deletion packages/cli-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@formatjs/cli-lib",
"version": "7.1.0",
"version": "7.1.2",
"description": "Lib for CLI for formatjs.",
"keywords": [
"intl",
26 changes: 16 additions & 10 deletions packages/cli-lib/src/verify/checkStructuralEquality.ts
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import {
parse,
} from '@formatjs/icu-messageformat-parser'
import {debug, writeStderr} from '../console_utils'
import {error} from 'console'

/**
* Flatten nested obj into list of keys, delimited by `.`
@@ -20,8 +21,9 @@ function flatten(obj: any, parentKey = ''): Record<string, string> {
const key = parentKey ? `${parentKey}.${k}` : k
if (typeof value === 'object') {
Object.assign(all, flatten(value, key))
} else {
all[key] = value
}
all[key] = value
return all
}, {})
}
@@ -38,26 +40,30 @@ export async function checkStructuralEquality(
const enUSMessages = Object.entries(flatten(enUSContent)).reduce<
Record<string, MessageFormatElement[]>
>((all, [key, value]) => {
all[key] = parse(value)
try {
all[key] = parse(value)
} catch (e) {
error('Error parsing message', key, value, e)
}
return all
}, {})
return Object.entries(translationFilesContents)
.filter(([locale]) => locale !== sourceLocale)
.reduce<boolean>((result, [locale, content]) => {
const localeMessages = Object.entries(flatten(content)).reduce<
Record<string, MessageFormatElement[]>
>((all, [key, value]) => {
all[key] = parse(value)
return all
}, {})
const localeMessages = flatten(content)

const problematicKeys = Object.keys(enUSMessages).filter(k => {
if (!localeMessages[k]) {
return false
}
const enUSMessage = enUSMessages[k]
const localeMessage = localeMessages[k]
return !isStructurallySame(enUSMessage, localeMessage)
try {
const localeMessage = parse(localeMessages[k])
return !isStructurallySame(enUSMessage, localeMessage)
} catch (e) {
error('Error comparing message', k, enUSMessage, localeMessages[k], e)
return true
}
})

if (!problematicKeys.length) {
12 changes: 12 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [6.4.2](https://github.com/formatjs/formatjs/compare/@formatjs/cli@6.4.1...@formatjs/cli@6.4.2) (2025-01-17)

### Bug Fixes

* **@formatjs/cli-lib:** fix flatten during structural equality check ([144453a](https://github.com/formatjs/formatjs/commit/144453a7a91af42678cb3c5b57d31673ef72b9cc)) - by @longlho

## [6.4.1](https://github.com/formatjs/formatjs/compare/@formatjs/cli@6.4.0...@formatjs/cli@6.4.1) (2025-01-17)

### Bug Fixes

* **@formatjs/cli-lib:** handle parsing error during verification ([ddca2c2](https://github.com/formatjs/formatjs/commit/ddca2c22899ce698f945927a35df6126c8cdbc48)) - by @longlho

# [6.4.0](https://github.com/formatjs/formatjs/compare/@formatjs/cli@6.3.15...@formatjs/cli@6.4.0) (2025-01-17)

### Features
Original file line number Diff line number Diff line change
@@ -4,5 +4,13 @@
"3": "bar {var, number}",
"4": "bar {var} {var2, number} {var3, date} {var4, time}",
"5": "bar {var} {var2, number} {var3, date} {var4, time} {var5, plural, one {# foo} other {# foos}}",
"6": "bar {var} {var2, number} {var3, date} {var4, time} {var5, plural, one {# foo} other {# foos}} <b>foo</b>"
"6": "bar {var} {var2, number} {var3, date} {var4, time} {var5, plural, one {# foo} other {# foos}} <b>foo</b>",
"7": "bb",
"8": {
"9": "bar",
"nested": {
"10": "bar"
}
},
"11": "nah"
}
Original file line number Diff line number Diff line change
@@ -4,5 +4,13 @@
"3": "bar {var, date}",
"4": "bar {var} {var2, number} {var3, date} {var5, time}",
"5": "bar {var} {var2, number} {var3, date} {var4, time} {var5, plural, one {# foo} other {# foos}}",
"6": "bar {var} {var2, number} {var3, date} {var4, time} {var5, plural, one {# foo} other {# foos}} foo"
"6": "bar {var} {var2, number} {var3, date} {var4, time} {var5, plural, one {# foo} other {# foos}} foo",
"7": "malform {a",
"8": {
"9": "bar",
"nested": {
"10": "bar"
}
},
"11": "nah"
}
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@formatjs/cli",
"version": "6.4.0",
"version": "6.4.2",
"description": "A CLI for formatjs.",
"keywords": [
"intl",