next-multilingual
Advanced tools
Comparing version 0.12.0 to 1.0.0
@@ -33,2 +33,3 @@ "use strict"; | ||
var path_1 = require("path"); | ||
var properties_file_1 = require("properties-file"); | ||
var template_1 = __importDefault(require("@babel/template")); | ||
@@ -38,3 +39,2 @@ var BabelTypes = __importStar(require("@babel/types")); | ||
var _1 = require("./"); | ||
var properties_1 = require("./properties"); | ||
var isImportNamespaceSpecifier = BabelTypes.isImportNamespaceSpecifier; | ||
@@ -96,9 +96,11 @@ var isImportSpecifier = BabelTypes.isImportSpecifier; | ||
function getMessages(propertiesFilePath) { | ||
var keyValueObject = (0, properties_1.parsePropertiesFile)(propertiesFilePath); | ||
var properties = (0, properties_file_1.getProperties)(propertiesFilePath); | ||
var context; | ||
var compactedKeyValueObject = {}; | ||
for (var key in keyValueObject) { | ||
var keySegments = key.split('.'); | ||
for (var _i = 0, _a = properties.collection; _i < _a.length; _i++) { | ||
var property = _a[_i]; | ||
var keySegments = property.key.split('.'); | ||
// Verify the key's format. | ||
if (keySegments.length !== 3) { | ||
__1.log.warn("unable to use messages in ".concat((0, __1.highlightFilePath)(propertiesFilePath), " because the key ").concat((0, __1.highlight)(key), " is invalid. It must follow the ").concat((0, __1.highlight)('<applicationId>.<context>.<id>'), " format.")); | ||
__1.log.warn("unable to use messages in ".concat((0, __1.highlightFilePath)(propertiesFilePath), " because the key ").concat((0, __1.highlight)(property.key), " is invalid. It must follow the ").concat((0, __1.highlight)('<applicationId>.<context>.<id>'), " format.")); | ||
return {}; | ||
@@ -109,3 +111,3 @@ } | ||
if (applicationIdSegment !== applicationId) { | ||
__1.log.warn("unable to use messages in ".concat((0, __1.highlightFilePath)(propertiesFilePath), " because the application identifier ").concat((0, __1.highlight)(applicationIdSegment), " in key ").concat((0, __1.highlight)(key), " is invalid. Expected value: ").concat((0, __1.highlight)(applicationId), ".")); | ||
__1.log.warn("unable to use messages in ".concat((0, __1.highlightFilePath)(propertiesFilePath), " because the application identifier ").concat((0, __1.highlight)(applicationIdSegment), " in key ").concat((0, __1.highlight)(property.key), " is invalid. Expected value: ").concat((0, __1.highlight)(applicationId), ".")); | ||
return {}; | ||
@@ -116,3 +118,3 @@ } | ||
if (!_1.keySegmentRegExp.test(contextSegment)) { | ||
__1.log.warn("unable to use messages in ".concat((0, __1.highlightFilePath)(propertiesFilePath), " because the context ").concat((0, __1.highlight)(contextSegment), " in key ").concat((0, __1.highlight)(key), " is invalid. Key context ").concat(_1.keySegmentRegExpDescription, ".")); | ||
__1.log.warn("unable to use messages in ".concat((0, __1.highlightFilePath)(propertiesFilePath), " because the context ").concat((0, __1.highlight)(contextSegment), " in key ").concat((0, __1.highlight)(property.key), " is invalid. Key context ").concat(_1.keySegmentRegExpDescription, ".")); | ||
return {}; | ||
@@ -123,3 +125,3 @@ } | ||
else if (contextSegment !== context) { | ||
__1.log.warn("unable to use messages in ".concat((0, __1.highlightFilePath)(propertiesFilePath), " because the context ").concat((0, __1.highlight)(contextSegment), " in key ").concat((0, __1.highlight)(key), " is invalid. Only one key context is allowed per file. Expected value: ").concat((0, __1.highlight)(context), ".")); | ||
__1.log.warn("unable to use messages in ".concat((0, __1.highlightFilePath)(propertiesFilePath), " because the context ").concat((0, __1.highlight)(contextSegment), " in key ").concat((0, __1.highlight)(property.key), " is invalid. Only one key context is allowed per file. Expected value: ").concat((0, __1.highlight)(context), ".")); | ||
return {}; | ||
@@ -129,8 +131,20 @@ } | ||
if (!_1.keySegmentRegExp.test(idSegment)) { | ||
__1.log.warn("unable to use messages in ".concat((0, __1.highlightFilePath)(propertiesFilePath), " because the identifier ").concat((0, __1.highlight)(idSegment), " in key ").concat((0, __1.highlight)(key), " is invalid. Key identifiers ").concat(_1.keySegmentRegExpDescription, ".")); | ||
__1.log.warn("unable to use messages in ".concat((0, __1.highlightFilePath)(propertiesFilePath), " because the identifier ").concat((0, __1.highlight)(idSegment), " in key ").concat((0, __1.highlight)(property.key), " is invalid. Key identifiers ").concat(_1.keySegmentRegExpDescription, ".")); | ||
return {}; | ||
} | ||
// If validation passes, keep only the identifier part of the key to reduce file sizes. | ||
compactedKeyValueObject[idSegment] = keyValueObject[key]; | ||
compactedKeyValueObject[idSegment] = property.value; | ||
} | ||
// Verify key collisions. | ||
if (Object.entries(compactedKeyValueObject).length) { | ||
var keyPrefix = "".concat(applicationId, ".").concat(context, "."); | ||
var keyCollisions = properties.getKeyCollisions(); | ||
for (var _b = 0, keyCollisions_1 = keyCollisions; _b < keyCollisions_1.length; _b++) { | ||
var keyCollision = keyCollisions_1[_b]; | ||
if (keyCollision.key.startsWith(keyPrefix)) { | ||
__1.log.warn("unable to use messages in ".concat((0, __1.highlightFilePath)(propertiesFilePath), " because the key ").concat((0, __1.highlight)(keyCollision.key), " has been used multiple times (lines ").concat((0, __1.highlight)(keyCollision.startingLineNumbers.join(', ')), ").")); | ||
return {}; | ||
} | ||
} | ||
} | ||
return compactedKeyValueObject; | ||
@@ -137,0 +151,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stripBom = exports.parsePropertiesFile = void 0; | ||
var dot_properties_1 = require("dot-properties"); | ||
var fs_1 = require("fs"); | ||
var content_1 = require("properties-file/content"); | ||
var __1 = require("../"); | ||
@@ -19,3 +19,3 @@ /** | ||
} | ||
return (0, dot_properties_1.parse)(fileContent); | ||
return (0, content_1.propertiesToJson)(fileContent); | ||
} | ||
@@ -22,0 +22,0 @@ exports.parsePropertiesFile = parsePropertiesFile; |
{ | ||
"name": "next-multilingual", | ||
"description": "An opinionated end-to-end solution for Next.js applications that requires multiple languages.", | ||
"version": "0.12.0", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
@@ -111,6 +111,6 @@ "main": "lib/index.js", | ||
"colorette": "^2.0.17", | ||
"dot-properties": "^1.0.1", | ||
"intl-messageformat": "^10.0.1", | ||
"intl-messageformat": "^10.1.0", | ||
"nookies": "^2.5.2", | ||
"resolve-accept-language": "^1.1.5" | ||
"properties-file": "^2.0.1", | ||
"resolve-accept-language": "^1.1.6" | ||
}, | ||
@@ -122,11 +122,11 @@ "devDependencies": { | ||
"@types/express": "^4.17.13", | ||
"@types/node": "^17.0.39", | ||
"@types/react": "^18.0.11", | ||
"@types/node": "^17.0.42", | ||
"@types/react": "^18.0.12", | ||
"@types/react-dom": "^18.0.5", | ||
"@typescript-eslint/eslint-plugin": "^5.27.0", | ||
"@typescript-eslint/parser": "^5.27.0", | ||
"@typescript-eslint/types": "^5.27.0", | ||
"@typescript-eslint/eslint-plugin": "^5.27.1", | ||
"@typescript-eslint/parser": "^5.27.1", | ||
"@typescript-eslint/types": "^5.27.1", | ||
"cross-env": "^7.0.3", | ||
"cypress": "^10.0.2", | ||
"cypress-fail-on-console-error": "^2.1.4", | ||
"cypress": "^10.1.0", | ||
"cypress-fail-on-console-error": "^3.0.0", | ||
"dotenv-cli": "^5.1.0", | ||
@@ -140,3 +140,3 @@ "eslint": "^8.17.0", | ||
"husky": "^8.0.1", | ||
"lint-staged": "^13.0.0", | ||
"lint-staged": "^13.0.1", | ||
"next": "v12.1.6", | ||
@@ -143,0 +143,0 @@ "npm-watch": "^0.11.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
250721
3922
0
+ Addedproperties-file@^2.0.1
+ Addedproperties-file@2.2.4(transitive)
- Removeddot-properties@^1.0.1
- Removeddot-properties@1.1.0(transitive)
Updatedintl-messageformat@^10.1.0