Skip to content

Commit

Permalink
Merge pull request #3 from SectorLabs/sort-object-keys
Browse files Browse the repository at this point in the history
Sort keys for messages and metadata
  • Loading branch information
Photonios committed Oct 17, 2018
2 parents 829c1e7 + 88bf9d2 commit e115539
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions dist/lingui-multi.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ const extractCatalogs = (packageFile, packageObject, localesDir, locales) => {

const minimalCatalog = Object.assign(createMinimalCatalog(complexCatalog), loadMinimalCatalogBypassErrors(localesDir, locale))

writeMinimalCatalog(minimalCatalog, localesDir, locale)
writeMinimalCatalog(sortObjectKeys(minimalCatalog), localesDir, locale)

// Write metadata catalog only to source locale directory
if (locale === options.sourceLocale) {
writeMetadataCatalog(complexCatalog, localesDir, locale)
writeMetadataCatalog(sortObjectKeys(complexCatalog), localesDir, locale)
}

console.info(`${locale} ${Object.keys(minimalCatalog).length}`)
Expand Down Expand Up @@ -266,6 +266,14 @@ const _getJsonFilePath = (directory, locale, suffix = '') => {
return jsonFile
}

const sortObjectKeys = (obj) => {
const sortedObj = {};
Object.keys(obj).sort().forEach(function(key) {
sortedObj[key] = obj[key];
});
return sortedObj;
}

const createMinimalCatalog = (complexCatalog) =>
Object.keys(complexCatalog)
.reduce((final, key) => Object.assign(final, {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sector-labs/lingui-multi",
"version": "1.0.18",
"version": "1.0.19",
"description": "Command line utility to compile multiple catalogs from a single js-lingui messages.json file.",
"repository": {
"url": "git+ssh://github.com/SectorLabs/lingui-multi.git",
Expand Down

0 comments on commit e115539

Please sign in to comment.